diff --git a/cmd/wm/client.c b/cmd/wm/client.c index d0749123..3a48b0f7 100644 --- a/cmd/wm/client.c +++ b/cmd/wm/client.c @@ -99,7 +99,9 @@ focus_client(Client *c) ungrab_mouse(c->win, AnyModifier, AnyButton); grab_mouse(c->win, Mod1Mask, Button1); grab_mouse(c->win, Mod1Mask, Button3); - XRaiseWindow(dpy, c->framewin); + + restack_tag(f->area->tag); + XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); draw_client(c); XSync(dpy, False); @@ -112,7 +114,7 @@ void map_client(Client *c) { XSelectInput(dpy, c->win, CLIENT_MASK & ~StructureNotifyMask); - XMapRaised(dpy, c->win); + XMapWindow(dpy, c->win); XSelectInput(dpy, c->win, CLIENT_MASK); set_client_state(c, NormalState); } diff --git a/cmd/wm/event.c b/cmd/wm/event.c index 312936ed..5940c123 100644 --- a/cmd/wm/event.c +++ b/cmd/wm/event.c @@ -91,7 +91,6 @@ handle_buttonpress(XEvent *e) else if((c = win2client(ev->window))) { ev->state &= valid_mask; if(ev->state & Mod1Mask) { - XRaiseWindow(dpy, c->framewin); switch (ev->button) { case Button1: focus(c); diff --git a/cmd/wm/tag.c b/cmd/wm/tag.c index 3d7def65..49183704 100644 --- a/cmd/wm/tag.c +++ b/cmd/wm/tag.c @@ -305,3 +305,32 @@ sel_client_of_tag(Tag *t) } return nil; } + +void +restack_tag(Tag *t) +{ + unsigned int i, j, n = 0; + static Window *wins = nil; + static unsigned int winssz = 0; + + if(nclient > winssz) { + winssz = 2 * nclient; + free(wins); + wins = cext_emallocz(sizeof(Window) * winssz); + } + + for(i = 0; i < t->narea; i++) { + Area *a = t->area[i]; + if(a->nframe) { + wins[n++] = a->frame[a->sel]->client->framewin; + for(j = 0; j < a->nframe; j++) { + if(j == a->sel) + continue; + wins[n++] = a->frame[j]->client->framewin; + } + } + } + + if(n) + XRestackWindows(dpy, wins, n); +} diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h index ad68e30b..c037db99 100644 --- a/cmd/wm/wm.h +++ b/cmd/wm/wm.h @@ -321,6 +321,7 @@ Bool clientoftag(Tag *t, Client *c); void detach_fromtag(Tag *t, Client *c, Bool unmap); void attach_totag(Tag *t, Client *c); Client *sel_client_of_tag(Tag *t); +void restack_tag(Tag *t); /* wm.c */ void scan_wins();