+ XLowerWindow(dpy, c->title);
+ XLowerWindow(dpy, c->win);
+}
+
+void
+manage(Window w, XWindowAttributes *wa)
+{
+ Client *c;
+ Window trans;
+ XSetWindowAttributes twa;
+
+ c = emallocz(sizeof(Client));
+ c->win = w;
+ c->x = c->tx = wa->x;
+ c->y = c->ty = wa->y;
+ c->w = c->tw = wa->width;
+ c->h = wa->height;
+ c->th = bh;
+
+ if(c->y < bh)
+ c->y = c->ty = 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);
+
+ settags(c);
+
+ if(clients)
+ clients->prev = c;
+ c->next = clients;
+ clients = c;
+
+ XGrabButton(dpy, Button1, MODKEY, c->win, False, ButtonPressMask,
+ GrabModeAsync, GrabModeSync, None, None);
+ XGrabButton(dpy, Button2, MODKEY, c->win, False, ButtonPressMask,
+ GrabModeAsync, GrabModeSync, None, None);
+ XGrabButton(dpy, Button3, MODKEY, c->win, False, ButtonPressMask,
+ GrabModeAsync, GrabModeSync, None, None);
+
+ if(!c->isfloat)
+ c->isfloat = trans || (c->maxw && c->minw &&
+ (c->maxw == c->minw) && (c->maxh == c->minh));
+
+
+ settitle(c);
+ arrange(NULL);
+
+ /* mapping the window now prevents flicker */
+ if(c->tags[tsel]) {
+ XMapRaised(dpy, c->win);
+ XMapRaised(dpy, c->title);
+ focus(c);
+ }
+ else {
+ XMapRaised(dpy, c->win);
+ XMapRaised(dpy, c->title);
+
+ }
+}
+
+void
+pop(Client *c)
+{
+ Client **l;
+
+ for(l = &clients; *l && *l != c; l = &(*l)->next);
+ if(c->prev)
+ c->prev->next = c->next;
+ if(c->next)
+ c->next->prev = c->prev;
+ *l = c->next;
+
+ c->prev = NULL;
+ if(clients)
+ clients->prev = c;
+ c->next = clients;
+ clients = c;
+ arrange(NULL);
+}
+
+void
+resize(Client *c, Bool sizehints, Corner sticky)
+{
+ int bottom = c->y + c->h;
+ int right = c->x + c->w;