+manage(Window w, XWindowAttributes *wa)
+{
+ Client *c;
+ XSetWindowAttributes twa;
+ Window trans;
+
+ c = emallocz(sizeof(Client));
+ c->win = w;
+ c->tx = c->x = wa->x;
+ c->ty = c->y = wa->y;
+ if(c->y < bh)
+ c->ty = c->y += bh;
+ c->tw = c->w = wa->width;
+ c->h = wa->height;
+ c->th = bh;
+ c->border = 1;
+ c->proto = getproto(c->win);
+ setsize(c);
+ XSelectInput(dpy, c->win,
+ StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
+ XGetTransientForHint(dpy, c->win, &trans);
+ twa.override_redirect = 1;
+ twa.background_pixmap = ParentRelative;
+ twa.event_mask = ExposureMask;
+
+ c->title = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th,
+ 0, DefaultDepth(dpy, screen), CopyFromParent,
+ DefaultVisual(dpy, screen),
+ CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
+
+ settitle(c);
+ settags(c);
+
+ c->next = clients;
+ clients = c;
+
+ XGrabButton(dpy, Button1, ControlMask, c->win, False, ButtonPressMask,
+ GrabModeAsync, GrabModeSync, None, None);
+ XGrabButton(dpy, Button1, Mod1Mask, c->win, False, ButtonPressMask,
+ GrabModeAsync, GrabModeSync, None, None);
+ XGrabButton(dpy, Button2, Mod1Mask, c->win, False, ButtonPressMask,
+ GrabModeAsync, GrabModeSync, None, None);
+ XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask,
+ GrabModeAsync, GrabModeSync, None, None);
+
+ if(!c->isfloat)
+ c->isfloat = trans
+ || ((c->maxw == c->minw) && (c->maxh == c->minh));
+
+ arrange(NULL);
+ /* mapping the window now prevents flicker */
+ if(c->tags[tsel]) {
+ XMapRaised(dpy, c->win);
+ XMapRaised(dpy, c->title);
+ focus(c);
+ }
+ else {
+ ban(c);
+ XMapRaised(dpy, c->win);
+ XMapRaised(dpy, c->title);
+ XSync(dpy, False);
+ }
+}
+
+void
+maximize(Arg *arg)
+{
+ if(!sel)
+ return;
+ sel->x = sx;
+ sel->y = sy + bh;
+ sel->w = sw - 2 * sel->border;
+ sel->h = sh - 2 * sel->border - bh;
+ higher(sel);
+ resize(sel, False);
+}
+
+void
+pop(Client *c)
+{
+ Client **l;
+ for(l = &clients; *l && *l != c; l = &(*l)->next);
+ *l = c->next;
+
+ c->next = clients; /* pop */
+ clients = c;
+ arrange(NULL);
+}
+
+void
+resize(Client *c, Bool inc)