]> git.sur5r.net Git - i3/i3/commitdiff
Bugfix: Set input focus with last timestamp
authorTony Crisci <tony@dubstepdish.com>
Thu, 12 Jun 2014 05:33:33 +0000 (01:33 -0400)
committerMichael Stapelberg <michael@stapelberg.de>
Thu, 12 Jun 2014 07:33:35 +0000 (09:33 +0200)
Setting input focus with the last event timestamp prevents race
conditions when setting focus.

fixes #1127

src/x.c

diff --git a/src/x.c b/src/x.c
index 086dbc9be4dab5102a632d8ba28a167a3172fcce..e48161db342fb6cd4d14e5fc0d2b2ad514499517 100644 (file)
--- a/src/x.c
+++ b/src/x.c
@@ -1026,7 +1026,7 @@ void x_push_changes(Con *con) {
                     values[0] = CHILD_EVENT_MASK & ~(XCB_EVENT_MASK_FOCUS_CHANGE);
                     xcb_change_window_attributes(conn, focused->window->id, XCB_CW_EVENT_MASK, values);
                 }
-                xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, to_focus, XCB_CURRENT_TIME);
+                xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, to_focus, last_timestamp);
                 if (focused->window != NULL) {
                     values[0] = CHILD_EVENT_MASK;
                     xcb_change_window_attributes(conn, focused->window->id, XCB_CW_EVENT_MASK, values);
@@ -1044,7 +1044,7 @@ void x_push_changes(Con *con) {
 
     if (focused_id == XCB_NONE) {
         DLOG("Still no window focused, better set focus to the root window\n");
-        xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, root, XCB_CURRENT_TIME);
+        xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, root, last_timestamp);
         ewmh_update_active_window(XCB_WINDOW_NONE);
         focused_id = root;
     }