Don't change focus in response to FocusIn events

Previously, when we received a FocusIn event, we would update the input focus,
because client_focus_update set globalconf.focus.need_update to true.

However, this is wrong for clients following the globally active focus model,
because in this case its the client which controls which window has the input
focus. It could happen that we thus took away the focus from the client which
just gave itself the focus.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2012-07-06 13:33:27 +02:00
parent 21d821a8dd
commit fc76521edb
1 changed files with 22 additions and 8 deletions

View File

@ -181,18 +181,27 @@ client_getbyframewin(xcb_window_t w)
return NULL;
}
/** Unfocus a client (internal).
* \param c The client.
*/
static void
client_unfocus_internal(client_t *c)
{
globalconf.focus.client = NULL;
luaA_object_push(globalconf.L, c);
luaA_object_emit_signal(globalconf.L, -1, "unfocus", 0);
lua_pop(globalconf.L, 1);
}
/** Unfocus a client.
* \param c The client.
*/
static void
client_unfocus(client_t *c)
{
globalconf.focus.client = NULL;
client_unfocus_internal(c);
globalconf.focus.need_update = true;
luaA_object_push(globalconf.L, c);
luaA_object_emit_signal(globalconf.L, -1, "unfocus", 0);
lua_pop(globalconf.L, 1);
}
/** Check if client supports atom a protocol in WM_PROTOCOL.
@ -281,11 +290,16 @@ client_focus_update(client_t *c)
if(globalconf.focus.client)
{
if (globalconf.focus.client != c)
client_unfocus(globalconf.focus.client);
else
if (globalconf.focus.client == c)
/* Already focused */
return;
/* When we are called due to a FocusIn event (=old focused client
* already unfocused), we don't want to cause a SetInputFocus,
* because the client which has focus now could be using globally
* active input model (or 'no input').
*/
client_unfocus_internal(globalconf.focus.client);
}
globalconf.focus.client = c;