diff --git a/client.c b/client.c index 5ad9814fc..47d646757 100644 --- a/client.c +++ b/client.c @@ -150,6 +150,7 @@ client_unfocus(Client *c) XSetWindowBorder(globalconf.display, c->win, globalconf.screens[c->screen].colors_normal[ColBorder].pixel); widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS); + focus_add_client(NULL); } /** Ban client and unmap it @@ -187,10 +188,10 @@ focus(Client *c, int screen) client_unfocus(globalconf.focus->client); /* save sel in focus history */ - focus_add_client(c); if(c) { + focus_add_client(c); XSetWindowBorder(globalconf.display, c->win, globalconf.screens[screen].colors_selected[ColBorder].pixel); XSetInputFocus(globalconf.display, c->win, RevertToPointerRoot, CurrentTime); diff --git a/layout.c b/layout.c index 50ba141c4..b3d49160d 100644 --- a/layout.c +++ b/layout.c @@ -81,6 +81,11 @@ arrange(int screen) if(!globalconf.screens[screen].allow_lower_floats) layout_raise_floatings(screen); + /* if we have a valid client that could be focused but currently no window + * are focused, then set the focus on this window */ + if((c = focus_get_current_client(screen)) && !globalconf.focus->client) + focus(c, screen); + /* reset status */ globalconf.screens[screen].need_arrange = False; }