-grabbuttons(Client *c, Bool focus)
-{
+detachstack(Client *c) {
+ Client **tc;
+ for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext);
+ *tc = c->snext;
+}
+
+static void
+grabbuttons(Client *c, Bool focused) {
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
XGrabButton(dpy, Button1, MODKEY, c->win, False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(dpy, Button1, MODKEY | LockMask, c->win, False, BUTTONMASK,
XGrabButton(dpy, Button1, MODKEY, c->win, False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(dpy, Button1, MODKEY | LockMask, c->win, False, BUTTONMASK,
else
XGrabButton(dpy, AnyButton, AnyModifier, c->win, False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
else
XGrabButton(dpy, AnyButton, AnyModifier, c->win, False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
XMoveResizeWindow(dpy, c->twin, c->tx, c->ty, c->tw, c->th);
else
XMoveResizeWindow(dpy, c->twin, c->tx + 2 * sw, c->ty, c->tw, c->th);
XMoveResizeWindow(dpy, c->twin, c->tx, c->ty, c->tw, c->th);
else
XMoveResizeWindow(dpy, c->twin, c->tx + 2 * sw, c->ty, c->tw, c->th);
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
XMoveWindow(dpy, c->twin, c->tx + 2 * sw, c->ty);
}
void
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
XMoveWindow(dpy, c->twin, c->tx + 2 * sw, c->ty);
}
void
- grabbuttons(old, False);
- drawtitle(old);
+ if(old) {
+ grabbuttons(old, False);
+ drawtitle(old);
+ }
+ }
+ if(c) {
+ detachstack(c);
+ c->snext = stack;
+ stack = c;
+ grabbuttons(c, True);
+ drawtitle(c);
+ XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
- grabbuttons(c, True);
- drawtitle(c);
- XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
+ else
+ XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
- if((tc = getclient(trans))) /* inherit tags */
- for(i = 0; i < ntags; i++)
- c->tags[i] = tc->tags[i];
- else
- settags(c);
+ settags(c, getclient(trans));
- XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
+ XConfigureWindow(dpy, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc);
- if(!sel)
- return;
-
- if((sel->ismax = !sel->ismax)) {
- ox = sel->x;
- oy = sel->y;
- ow = sel->w;
- oh = sel->h;
- sel->x = sx;
- sel->y = sy + bh;
- sel->w = sw - 2;
- sel->h = sh - 2 - bh;
-
- restack();
- resize(sel, arrange == dofloat, TopLeft);
-
- sel->x = ox;
- sel->y = oy;
- sel->w = ow;
- sel->h = oh;
- }
- else
- resize(sel, False, TopLeft);
- while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
-}
-
-void
-unmanage(Client *c)
-{
- Client *tc;
- Window trans;
+ /* The server grab construct avoids race conditions. */
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
XDestroyWindow(dpy, c->twin);
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
XDestroyWindow(dpy, c->twin);