]> git.sur5r.net Git - i3/i3/commitdiff
Refocus focused window for FOCUS_IN events on the root window. (#3097)
authorIngo Bürk <admin@airblader.de>
Sat, 10 Mar 2018 18:18:44 +0000 (19:18 +0100)
committerMichael Stapelberg <stapelberg@users.noreply.github.com>
Sat, 10 Mar 2018 18:18:44 +0000 (19:18 +0100)
This deals with (admittedly somewhat misbehaving) clients which
use XSetInputFocus to take focus, but then don't properly restore
focus. This has been observed with TK apps, but also, e.g., Steam.

fixes #2722
fixes #3096

include/xcb.h
src/handlers.c

index 92be7b895511f5f16913fe178a58db878993af27..53c932bfb1a11cbb3f919da17b32e9772573afa7 100644 (file)
@@ -53,6 +53,7 @@
                                                                   ConfigureNotify */                  \
                          XCB_EVENT_MASK_POINTER_MOTION |                                              \
                          XCB_EVENT_MASK_PROPERTY_CHANGE |                                             \
+                         XCB_EVENT_MASK_FOCUS_CHANGE |                                                \
                          XCB_EVENT_MASK_ENTER_WINDOW)
 
 #define xmacro(atom) xcb_atom_t A_##atom;
index e1671c3b4bec2df918fdf70d89d38a29ee77c0d1..50fd85669223267e123a97ebe5bdfea09c9ab1e3 100644 (file)
@@ -1207,6 +1207,14 @@ static bool handle_clientleader_change(void *data, xcb_connection_t *conn, uint8
  */
 static void handle_focus_in(xcb_focus_in_event_t *event) {
     DLOG("focus change in, for window 0x%08x\n", event->event);
+
+    if (event->event == root) {
+        DLOG("Received focus in for root window, refocusing the focused window.\n");
+        con_focus(focused);
+        focused_id = XCB_NONE;
+        x_push_changes(croot);
+    }
+
     Con *con;
     if ((con = con_by_window_id(event->event)) == NULL || con->window == NULL)
         return;