From f711503d7b57f3f8762a1955b43c4da7e599864d Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Thu, 19 Feb 2009 16:27:06 +0100 Subject: [PATCH] client: call unfocus hook when we changed focused client (FS#454) Signed-off-by: Julien Danjou --- client.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/client.c b/client.c index ac186dad..e17951d2 100644 --- a/client.c +++ b/client.c @@ -286,15 +286,8 @@ client_focus(client_t *c) if (!window_hasproto(c->win, WM_TAKE_FOCUS) && c->nofocus) return; - /* unfocus current selected client - * We don't really need to unfocus here, - * because client already received FocusOut event. - * What we need to do is call unfocus hook, to - * inform lua script, about this event. - */ - if(globalconf.screen_focus->client_focus - && c != globalconf.screen_focus->client_focus) - client_unfocus_hook(globalconf.screen_focus->client_focus); + /* Save current focused client */ + client_t *focused_before = globalconf.screen_focus->client_focus; /* stop hiding c */ c->ishidden = false; @@ -319,6 +312,15 @@ client_focus(client_t *c) * And anyway, we have maybe unhidden */ client_need_arrange(c); + /* unfocus current selected client + * We don't really need to unfocus here, + * because client already received FocusOut event. + * What we need to do is call unfocus hook, to + * inform lua script, about this event. + */ + if(focused_before && c != focused_before) + client_unfocus_hook(focused_before); + /* execute hook */ if(globalconf.hooks.focus != LUA_REFNIL) {