]> git.sur5r.net Git - i3/i3/commitdiff
Send WM_TAKE_FOCUS to clients when setting focus (fixes java swing problems)
authorMichael Stapelberg <michael@stapelberg.de>
Thu, 17 Mar 2011 21:27:59 +0000 (22:27 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Thu, 17 Mar 2011 21:27:59 +0000 (22:27 +0100)
include/xcb.h
src/main.c
src/x.c

index 8b531a3417016325251c388972ff8a8b3662182b..47eec76b6be0d69999d5c8b602e2417e2763490c 100644 (file)
@@ -67,6 +67,7 @@ enum {
     _NET_CURRENT_DESKTOP,
     _NET_ACTIVE_WINDOW,
     _NET_WORKAREA,
+    WM_TAKE_FOCUS,
     NUM_ATOMS
 };
 
index 9ab578d1968535071c65c99ca6b8c61cd4433529..002eb6a5729a93df1988f1bd7121baef09b5d097 100644 (file)
@@ -295,6 +295,7 @@ int main(int argc, char *argv[]) {
     REQUEST_ATOM(_NET_CURRENT_DESKTOP);
     REQUEST_ATOM(_NET_ACTIVE_WINDOW);
     REQUEST_ATOM(_NET_WORKAREA);
+    REQUEST_ATOM(WM_TAKE_FOCUS);
 
     /* Initialize the Xlib connection */
     xlibdpy = xkbdpy = XOpenDisplay(NULL);
@@ -398,6 +399,7 @@ int main(int argc, char *argv[]) {
     GET_ATOM(_NET_CURRENT_DESKTOP);
     GET_ATOM(_NET_ACTIVE_WINDOW);
     GET_ATOM(_NET_WORKAREA);
+    GET_ATOM(WM_TAKE_FOCUS);
 
     /* Watch _NET_WM_NAME (title of the window encoded in UTF-8) */
     xcb_property_set_handler(&prophs, atoms[_NET_WM_NAME], 128, handle_windowname_change, NULL);
diff --git a/src/x.c b/src/x.c
index 64201ead6430966ac16668e9aa3d9046337287b5..7a3385e5b86d14e8ea5d06f83fafb07d01960012 100644 (file)
--- a/src/x.c
+++ b/src/x.c
@@ -616,6 +616,22 @@ void x_push_changes(Con *con) {
         } else {
             DLOG("Updating focus (focused: %p / %s)\n", focused, focused->name);
             xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, to_focus, XCB_CURRENT_TIME);
+
+            /* TODO: check if that client acccepts WM_TAKE_FOCUS at all */
+            xcb_client_message_event_t ev;
+
+            memset(&ev, 0, sizeof(xcb_client_message_event_t));
+
+            ev.response_type = XCB_CLIENT_MESSAGE;
+            ev.window = to_focus;
+            ev.type = atoms[WM_PROTOCOLS];
+            ev.format = 32;
+            ev.data.data32[0] = atoms[WM_TAKE_FOCUS];
+            ev.data.data32[1] = XCB_CURRENT_TIME;
+
+            DLOG("Sending WM_TAKE_FOCUS to the client\n");
+            xcb_send_event(conn, false, to_focus, XCB_EVENT_MASK_NO_EVENT, (char*)&ev);
+
             ewmh_update_active_window(to_focus);
             focused_id = to_focus;
         }