← easystroke

Don't give focus to override_redirect windows

91becc2dd254d07403f44bf6cf6b407b5082621b · Thomas Jaeger · Aug 9, 2011 02:03

Window managers don't seem to do this.

+10 −5 · 1 file changed

  • main.cc +10 −5
diff --git a/main.cc b/main.cc
index dbf06a1..1551001 100644
--- a/main.cc
+++ b/main.cc
@@ -682,6 +682,7 @@ static void activate_window(Window w, Time t) {
 	Atom window_type = get_atom(w, *_NET_WM_WINDOW_TYPE);
 	if (window_type == *_NET_WM_WINDOW_TYPE_DOCK)
 		return;
+
 	XWMHints *wm_hints = XGetWMHints(dpy, w);
 	if (wm_hints) {
 		bool input = wm_hints->input;
@@ -689,14 +690,18 @@ static void activate_window(Window w, Time t) {
 		if (!input)
 			return;
 	}
+
+	if (!has_atom(w, *WM_PROTOCOLS, *WM_TAKE_FOCUS))
+		return;
+
+	XWindowAttributes attr;
+	if (XGetWindowAttributes(dpy, w, &attr) && attr.override_redirect)
+		return;
+
 	if (verbosity >= 3)
 		printf("Giving focus to window 0x%lx\n", w);
 
-	bool take_focus = has_atom(w, *WM_PROTOCOLS, *WM_TAKE_FOCUS);
-	if (take_focus)
-		icccm_client_message(w, *WM_TAKE_FOCUS, t);
-	else
-		XSetInputFocus(dpy, w, RevertToParent, t);
+	icccm_client_message(w, *WM_TAKE_FOCUS, t);
 }
 
 void Trace::start(Trace::Point p) {