diff --git a/client.c b/client.c index f726ca590..dd854c210 100644 --- a/client.c +++ b/client.c @@ -335,6 +335,19 @@ client_set_focus(client_t *c, bool set_input_focus) window_takefocus(c->window); } +/** Prepare banning a client by running all needed lua events. + * \param c The client. + */ +void client_ban_unfocus(client_t *c) +{ + if(globalconf.screens.tab[c->phys_screen].prev_client_focus == c) + globalconf.screens.tab[c->phys_screen].prev_client_focus = NULL; + + /* Wait until the last moment to take away the focus from the window. */ + if(globalconf.screens.tab[c->phys_screen].client_focus == c) + client_unfocus(c); +} + /** Ban client and move it out of the viewport. * \param c The client. */ @@ -347,12 +360,7 @@ client_ban(client_t *c) c->isbanned = true; - if(globalconf.screens.tab[c->phys_screen].prev_client_focus == c) - globalconf.screens.tab[c->phys_screen].prev_client_focus = NULL; - - /* Wait until the last moment to take away the focus from the window. */ - if(globalconf.screens.tab[c->phys_screen].client_focus == c) - client_unfocus(c); + client_ban_unfocus(c); } } diff --git a/client.h b/client.h index 39d20fa0c..a270a651c 100644 --- a/client.h +++ b/client.h @@ -163,6 +163,7 @@ LUA_OBJECT_FUNCS(client_class, client_t, client) bool client_maybevisible(client_t *, screen_t *); client_t * client_getbywin(xcb_window_t); void client_ban(client_t *); +void client_ban_unfocus(client_t *); void client_unban(client_t *); void client_manage(xcb_window_t, xcb_get_geometry_reply_t *, int, bool); area_t client_geometry_hints(client_t *, area_t);