From dea5a23eac7e54c60df5771caa0ee28b3f1fc8e8 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 6 Nov 2014 19:48:35 +0100 Subject: [PATCH] Remove urgent state for already focused client - Remove urgent state in `client_focus_update` always. - Make `client_focus_update` indicate if focus changed and use this from `client_focus` to update `globalconf.focus.need_update`. Fixes: https://awesome.naquadah.org/bugs/index.php?do=details&task_id=1310 --- objects/client.c | 28 ++++++++++++++-------------- objects/client.h | 4 ++-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/objects/client.c b/objects/client.c index 644b838b..1e2ea4f8 100644 --- a/objects/client.c +++ b/objects/client.c @@ -294,21 +294,18 @@ client_restore_enterleave_events(void) /** Record that a client got focus. * \param c The client. + * \return true if the client focus changed, false otherwise. */ -void +bool client_focus_update(client_t *c) { lua_State *L = globalconf_get_lua_State(); if(!client_maybevisible(c)) - return; + return false; - if(globalconf.focus.client) + if(globalconf.focus.client && globalconf.focus.client != c) { - 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 @@ -317,14 +314,20 @@ client_focus_update(client_t *c) client_unfocus_internal(globalconf.focus.client); } + bool focused_new = globalconf.focus.client != c; globalconf.focus.client = c; - /* according to EWMH, we have to remove the urgent state from a client */ + /* According to EWMH, we have to remove the urgent state from a client. + * This should be done also for the current/focused client (FS#1310). */ luaA_object_push(L, c); client_set_urgent(L, -1, false); - luaA_object_emit_signal(L, -1, "focus", 0); + if(focused_new) + luaA_object_emit_signal(L, -1, "focus", 0); + lua_pop(L, 1); + + return focused_new; } /** Give focus to client, or to first client if client is NULL. @@ -337,11 +340,8 @@ client_focus(client_t *c) if(!c && globalconf.clients.len && !(c = globalconf.clients.tab[0])) return; - if(!client_maybevisible(c) || c == globalconf.focus.client) - return; - - client_focus_update(c); - globalconf.focus.need_update = true; + if(client_focus_update(c)) + globalconf.focus.need_update = true; } void diff --git a/objects/client.h b/objects/client.h index fba25595..2955d573 100644 --- a/objects/client.h +++ b/objects/client.h @@ -170,7 +170,7 @@ void client_set_icon(client_t *, cairo_surface_t *); void client_set_icon_from_pixmaps(client_t *, xcb_pixmap_t, xcb_pixmap_t); void client_set_skip_taskbar(lua_State *, int, bool); void client_focus(client_t *); -void client_focus_update(client_t *); +bool client_focus_update(client_t *); bool client_hasproto(client_t *, xcb_atom_t); void client_ignore_enterleave_events(void); void client_restore_enterleave_events(void); @@ -222,7 +222,7 @@ client_isfixed(client_t *c) && c->size_hints_honor); } -/** Returns true if a client is tagged with one of the tags of the +/** Returns true if a client is tagged with one of the tags of the * specified screen and is not hidden. Note that "banned" clients are included. * \param c The client to check. * \param screen Virtual screen number.