Ensure that input focus is returned to correct window when i3lock quits - #302
Ensure that input focus is returned to correct window when i3lock quits#302CometStorm991 wants to merge 1 commit into
Conversation
Raymo111
left a comment
There was a problem hiding this comment.
Review — Approve with nits
What it does: Adds one line to the exit path of main() that sets X input focus back to stolen_focus immediately after the existing set_focused_window() call, fixing cases (notably --composite) where focus otherwise reverts to the wrong window.
Correctness: Sound and matches intent. stolen_focus is captured from the root's _NET_ACTIVE_WINDOW (the WM's real managed client), not i3lock's win nor the composite overlay, so targeting it with xcb_set_input_focus is correct. The added call is reached only when stolen_focus != XCB_NONE, so the value is always valid here. Ordering is fine — it runs after xcb_destroy_window(win), so it overrides X's automatic focus-revert (which, under --composite, would land on the overlay window rather than the original client). Applies cleanly to current master.
Nit: set_focused_window() and the new set_input_focus() now both fire and look redundant at a glance — they're actually complementary (the former updates the WM's active-window state, the latter fixes the raw X input focus). A one-line comment explaining why both are kept would help future readers.
Recommendation: Merge — small, correct, well-motivated fix with no functional downside.
Description
--compositeoption is enabled, the parent window set byparent_win = composite_reply->overlay_win;inxcb.ccan be different from the window from which focus was stolen.--compositeoption is enabled) as shown below (comments removed)xcb_set_input_focus(conn, XCB_INPUT_FOCUS_PARENT /* revert_to */, stolen_focus, XCB_CURRENT_TIME);to the end ofmain(...), ensures that focus returns to the correct windowstolen_focus.