From 10fa808a5af56d3c67bd6255991eae607a3b20ae Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 8 Jul 2012 15:41:16 +0200 Subject: [PATCH] Ignore (Un)Grab focus notifies When a keyboard grab activate/deactives, the input focus jumps to the window which does the grab. These FocusIn events sometimes managed to confuse awesome. The symptom was that a newly mapped/started client didn't receive the input focus: - You press your key-combo to start a terminal. This activates a passive grab and the input focus jumps to the root window - The terminal opens and the "manage" rule does client.focus = c - This doesn't set the focus yet, but instead causes globalconf.focus.need_update = true and .client = new_terminal - Before the focus is updated, the key combo is released and the focus jumps back to the previously focused client - The FocusIn with mode == Ungrab causes awesome to think that the previously focused client got focused again and thus globalconf.client.focus gets re-set to what it was before - Finally the focus is refreshed and the previously focused client gets focused The fix is simple: We don't need the FocusIn events which are generated when a grab activates or deactivates, so we can just ignore them. Thanks to Majic for reporting this to me. Signed-off-by: Uli Schlachter --- event.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/event.c b/event.c index 7e7406e1..03bc5d81 100644 --- a/event.c +++ b/event.c @@ -459,6 +459,11 @@ event_handle_enternotify(xcb_enter_notify_event_t *ev) static void event_handle_focusin(xcb_focus_in_event_t *ev) { + if (ev->mode == XCB_NOTIFY_MODE_GRAB + || ev->mode == XCB_NOTIFY_MODE_UNGRAB) + /* Ignore focus changes due to keyboard grabs */ + return; + /* Events that we are interested in: */ switch(ev->detail) {