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 <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2012-07-08 15:41:16 +02:00
parent 41283f508c
commit 10fa808a5a
1 changed files with 5 additions and 0 deletions

View File

@ -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)
{