-unban(Client *c) {
- if(!c->isbanned)
- return;
- XMoveWindow(dpy, c->win, c->x, c->y);
- c->isbanned = False;
-}
-
-static void
-unmanage(Client *c) {
- XWindowChanges wc;
-
- wc.border_width = c->oldborder;
- /* The server grab construct avoids race conditions. */
- XGrabServer(dpy);
- XSetErrorHandler(xerrordummy);
- XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); /* restore border */
- detach(c);
- detachstack(c);
- if(sel == c)
- focus(NULL);
- XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
- setclientstate(c, WithdrawnState);
- free(c->tags);
- free(c);
- XSync(dpy, False);
- XSetErrorHandler(xerror);
- XUngrabServer(dpy);
- arrange();
-}
-
-static void
-updatesizehints(Client *c) {
- long msize;
- XSizeHints size;
-
- if(!XGetWMNormalHints(dpy, c->win, &size, &msize) || !size.flags)
- size.flags = PSize;
- c->flags = size.flags;
- if(c->flags & PBaseSize) {
- c->basew = size.base_width;
- c->baseh = size.base_height;
- }
- else if(c->flags & PMinSize) {
- c->basew = size.min_width;
- c->baseh = size.min_height;
- }
- else
- c->basew = c->baseh = 0;
- if(c->flags & PResizeInc) {
- c->incw = size.width_inc;
- c->inch = size.height_inc;
- }
- else
- c->incw = c->inch = 0;
- if(c->flags & PMaxSize) {
- c->maxw = size.max_width;
- c->maxh = size.max_height;
- }
- else
- c->maxw = c->maxh = 0;
- if(c->flags & PMinSize) {
- c->minw = size.min_width;
- c->minh = size.min_height;
- }
- else if(c->flags & PBaseSize) {
- c->minw = size.base_width;
- c->minh = size.base_height;
- }
- else
- c->minw = c->minh = 0;
- if(c->flags & PAspect) {
- c->minax = size.min_aspect.x;
- c->maxax = size.max_aspect.x;
- c->minay = size.min_aspect.y;
- c->maxay = size.max_aspect.y;
- }
- else
- c->minax = c->maxax = c->minay = c->maxay = 0;
- c->isfixed = (c->maxw && c->minw && c->maxh && c->minh
- && c->maxw == c->minw && c->maxh == c->minh);
-}
-
-static void
-updatetitle(Client *c) {
- if(!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name))
- gettextprop(c->win, wmatom[WMName], c->name, sizeof c->name);
-}
-
-static Client *
-getclient(Window w) {
- Client *c;
-
- for(c = clients; c && c->win != w; c = c->next);
- return c;
-}
-
-static void
-movemouse(Client *c) {
- int x1, y1, ocx, ocy, di, nx, ny;
- unsigned int dui;
- Window dummy;
- XEvent ev;
-
- ocx = nx = c->x;
- ocy = ny = c->y;
- if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
- None, cursor[CurMove], CurrentTime) != GrabSuccess)
- return;
- c->ismax = False;
- XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
- for(;;) {
- XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev);
- switch (ev.type) {
- case ButtonRelease:
- XUngrabPointer(dpy, CurrentTime);
- return;
- case ConfigureRequest:
- case Expose:
- case MapRequest:
- handler[ev.type](&ev);
- break;
- case MotionNotify:
- XSync(dpy, False);
- nx = ocx + (ev.xmotion.x - x1);
- ny = ocy + (ev.xmotion.y - y1);
- if(abs(wax + nx) < SNAP)
- nx = wax;
- else if(abs((wax + waw) - (nx + c->w + 2 * c->border)) < SNAP)
- nx = wax + waw - c->w - 2 * c->border;
- if(abs(way - ny) < SNAP)
- ny = way;
- else if(abs((way + wah) - (ny + c->h + 2 * c->border)) < SNAP)
- ny = way + wah - c->h - 2 * c->border;
- resize(c, nx, ny, c->w, c->h, False);
- break;
- }
- }
-}
-
-static void
-resizemouse(Client *c) {
- int ocx, ocy;
- int nw, nh;
- XEvent ev;