Split restack function out of focus, and fix click-to-raise
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
c39d8c2a7e
commit
c5afa7753b
101
client.c
101
client.c
|
@ -211,54 +211,7 @@ client_focus(Client *c, int screen, Bool raise)
|
||||||
titlebar_update(c);
|
titlebar_update(c);
|
||||||
XSetInputFocus(globalconf.display, c->win, RevertToPointerRoot, CurrentTime);
|
XSetInputFocus(globalconf.display, c->win, RevertToPointerRoot, CurrentTime);
|
||||||
if(raise)
|
if(raise)
|
||||||
{
|
client_stack(c);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* since we're dropping EnterWindow events and sometimes the window
|
/* since we're dropping EnterWindow events and sometimes the window
|
||||||
* will appear under the mouse, grabbuttons */
|
* will appear under the mouse, grabbuttons */
|
||||||
window_grabbuttons(c->win, c->phys_screen);
|
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);
|
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
|
/** Manage a new client
|
||||||
* \param w The window
|
* \param w The window
|
||||||
* \param wa Window attributes
|
* \param wa Window attributes
|
||||||
|
|
1
client.h
1
client.h
|
@ -28,6 +28,7 @@ Bool client_isvisible(Client *, int);
|
||||||
Client * client_get_bywin(Client *, Window);
|
Client * client_get_bywin(Client *, Window);
|
||||||
Client * client_get_byname(Client *, char *);
|
Client * client_get_byname(Client *, char *);
|
||||||
void client_focus(Client *, int, Bool);
|
void client_focus(Client *, int, Bool);
|
||||||
|
void client_stack(Client *);
|
||||||
void client_ban(Client *);
|
void client_ban(Client *);
|
||||||
void client_unban(Client *);
|
void client_unban(Client *);
|
||||||
void client_manage(Window, XWindowAttributes *, int);
|
void client_manage(Window, XWindowAttributes *, int);
|
||||||
|
|
5
event.c
5
event.c
|
@ -127,7 +127,7 @@ event_handle_buttonpress(XEvent *e)
|
||||||
|
|
||||||
if((c = client_get_bywin(globalconf.clients, ev->window)))
|
if((c = client_get_bywin(globalconf.clients, ev->window)))
|
||||||
{
|
{
|
||||||
client_focus(c, c->screen, True);
|
client_stack(c);
|
||||||
if(CLEANMASK(ev->state) == NoSymbol
|
if(CLEANMASK(ev->state) == NoSymbol
|
||||||
&& ev->button == Button1)
|
&& ev->button == Button1)
|
||||||
{
|
{
|
||||||
|
@ -266,8 +266,7 @@ event_handle_enternotify(XEvent *e)
|
||||||
window_grabbuttons(c->win, c->phys_screen);
|
window_grabbuttons(c->win, c->phys_screen);
|
||||||
if(globalconf.screens[c->screen].sloppy_focus)
|
if(globalconf.screens[c->screen].sloppy_focus)
|
||||||
client_focus(c, c->screen,
|
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
|
else
|
||||||
for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
|
for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
|
||||||
|
|
Loading…
Reference in New Issue