Bugfix: Set input focus with last timestamp
Patch status: merged
Patch by Tony Crisci
Long description:
Setting input focus with the last event timestamp prevents race conditions when setting focus. fixes #1127
To apply this patch, use:
curl http://cr.i3wm.org/patch/573/raw.patch | git am
b/src/x.c
17 |
@@ -1026,7 +1026,7 @@ void x_push_changes(Con *con) { |
18 |
values[0] = CHILD_EVENT_MASK & ~(XCB_EVENT_MASK_FOCUS_CHANGE); |
19 |
xcb_change_window_attributes(conn, focused->window->id, XCB_CW_EVENT_MASK, values); |
20 |
} |
21 |
- xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, to_focus, XCB_CURRENT_TIME); |
22 |
+ xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, to_focus, last_timestamp); |
23 |
if (focused->window != NULL) { |
24 |
values[0] = CHILD_EVENT_MASK; |
25 |
xcb_change_window_attributes(conn, focused->window->id, XCB_CW_EVENT_MASK, values); |
26 |
@@ -1044,7 +1044,7 @@ void x_push_changes(Con *con) { |
27 |
|
28 |
if (focused_id == XCB_NONE) { |
29 |
DLOG("Still no window focused, better set focus to the root window\n"); |
30 |
- xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, root, XCB_CURRENT_TIME); |
31 |
+ xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, root, last_timestamp); |
32 |
ewmh_update_active_window(XCB_WINDOW_NONE); |
33 |
focused_id = root; |
34 |
} |