diff --git a/client.c b/client.c index 7e3d6dc5a..961ecf681 100644 --- a/client.c +++ b/client.c @@ -211,54 +211,7 @@ client_focus(Client *c, int screen, Bool raise) titlebar_update(c); XSetInputFocus(globalconf.display, c->win, RevertToPointerRoot, CurrentTime); if(raise) - { - XWindowChanges wc; - Layout *curlay = layout_get_current(screen); - if(c->isfloating || curlay->arrange == layout_floating) - { - XRaiseWindow(globalconf.display, c->win); - if(c->titlebar.position && c->titlebar.sw) - XRaiseWindow(globalconf.display, c->titlebar.sw->window); - } - else - { - Client *client; - wc.stack_mode = Below; - wc.sibling = None; - for(client = globalconf.clients; client; client = client->next) - if(client != c && client_isvisible(client, c->screen) && client->isfloating) - { - if(client->titlebar.position && client->titlebar.sw) - { - XConfigureWindow(globalconf.display, client->titlebar.sw->window, - CWSibling | CWStackMode, &wc); - wc.sibling = client->titlebar.sw->window; - } - XConfigureWindow(globalconf.display, client->win, CWSibling | CWStackMode, &wc); - wc.sibling = client->win; - } - if(c->titlebar.position && c->titlebar.sw) - { - XConfigureWindow(globalconf.display, c->titlebar.sw->window, - CWSibling | CWStackMode, &wc); - wc.sibling = c->titlebar.sw->window; - } - XConfigureWindow(globalconf.display, c->win, CWSibling | CWStackMode, &wc); - wc.sibling = c->win; - for(client = globalconf.clients; client; client = client->next) - if(client != c && IS_TILED(client, c->screen)) - { - if(client->titlebar.position && client->titlebar.sw) - { - XConfigureWindow(globalconf.display, client->titlebar.sw->window, - CWSibling | CWStackMode, &wc); - wc.sibling = client->titlebar.sw->window; - } - XConfigureWindow(globalconf.display, client->win, CWSibling | CWStackMode, &wc); - wc.sibling = client->win; - } - } - } + client_stack(c); /* since we're dropping EnterWindow events and sometimes the window * will appear under the mouse, grabbuttons */ window_grabbuttons(c->win, c->phys_screen); @@ -272,6 +225,58 @@ client_focus(Client *c, int screen, Bool raise) ewmh_update_net_active_window(c->phys_screen); } +void +client_stack(Client *c) +{ + XWindowChanges wc; + Layout *curlay = layout_get_current(c->screen); + + if(c->isfloating || curlay->arrange == layout_floating) + { + XRaiseWindow(globalconf.display, c->win); + if(c->titlebar.position && c->titlebar.sw) + XRaiseWindow(globalconf.display, c->titlebar.sw->window); + } + else + { + Client *client; + wc.stack_mode = Below; + wc.sibling = None; + for(client = globalconf.clients; client; client = client->next) + if(client != c && client_isvisible(client, c->screen) && client->isfloating) + { + if(client->titlebar.position && client->titlebar.sw) + { + XConfigureWindow(globalconf.display, client->titlebar.sw->window, + CWSibling | CWStackMode, &wc); + wc.sibling = client->titlebar.sw->window; + } + XConfigureWindow(globalconf.display, client->win, CWSibling | CWStackMode, &wc); + wc.sibling = client->win; + } + if(c->titlebar.position && c->titlebar.sw) + { + XConfigureWindow(globalconf.display, c->titlebar.sw->window, + CWSibling | CWStackMode, &wc); + wc.sibling = c->titlebar.sw->window; + } + XConfigureWindow(globalconf.display, c->win, CWSibling | CWStackMode, &wc); + wc.sibling = c->win; + for(client = globalconf.clients; client; client = client->next) + if(client != c && IS_TILED(client, c->screen)) + { + if(client->titlebar.position && client->titlebar.sw) + { + XConfigureWindow(globalconf.display, client->titlebar.sw->window, + CWSibling | CWStackMode, &wc); + wc.sibling = client->titlebar.sw->window; + } + XConfigureWindow(globalconf.display, client->win, CWSibling | CWStackMode, &wc); + wc.sibling = client->win; + } + } +} + /** Manage a new client * \param w The window * \param wa Window attributes diff --git a/client.h b/client.h index 4e43923d9..9456cb8be 100644 --- a/client.h +++ b/client.h @@ -28,6 +28,7 @@ Bool client_isvisible(Client *, int); Client * client_get_bywin(Client *, Window); Client * client_get_byname(Client *, char *); void client_focus(Client *, int, Bool); +void client_stack(Client *); void client_ban(Client *); void client_unban(Client *); void client_manage(Window, XWindowAttributes *, int); diff --git a/event.c b/event.c index 421dd013d..974d8b973 100644 --- a/event.c +++ b/event.c @@ -127,7 +127,7 @@ event_handle_buttonpress(XEvent *e) if((c = client_get_bywin(globalconf.clients, ev->window))) { - client_focus(c, c->screen, True); + client_stack(c); if(CLEANMASK(ev->state) == NoSymbol && ev->button == Button1) { @@ -266,8 +266,7 @@ event_handle_enternotify(XEvent *e) window_grabbuttons(c->win, c->phys_screen); if(globalconf.screens[c->screen].sloppy_focus) client_focus(c, c->screen, - (globalconf.screens[c->screen].sloppy_focus - && globalconf.screens[c->screen].sloppy_focus_raise)); + globalconf.screens[c->screen].sloppy_focus_raise); } else for(screen = 0; screen < ScreenCount(e->xany.display); screen++)