From fc76521edb011c30b33f9174e762e561f94f1fda Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Fri, 6 Jul 2012 13:33:27 +0200 Subject: [PATCH] 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 --- objects/client.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/objects/client.c b/objects/client.c index a5b9d777..0df0fa7e 100644 --- a/objects/client.c +++ b/objects/client.c @@ -181,20 +181,29 @@ client_getbyframewin(xcb_window_t w) return NULL; } -/** Unfocus a client. +/** Unfocus a client (internal). * \param c The client. */ static void -client_unfocus(client_t *c) +client_unfocus_internal(client_t *c) { globalconf.focus.client = NULL; - 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); } +/** Unfocus a client. + * \param c The client. + */ +static void +client_unfocus(client_t *c) +{ + client_unfocus_internal(c); + globalconf.focus.need_update = true; +} + /** Check if client supports atom a protocol in WM_PROTOCOL. * \param c The client. * \param atom The protocol atom to check for. @@ -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; -- 2.11.4.GIT