void spiral(Client *c, float fact, XRectangle *r, XRectangle *rp) { static int pos = 1; float f = fact == 1 ? 1 : 0.5; switch(pos) { case 0: /* left */ rp->x = r->x; rp->y = r->y; rp->width = r->width * f; rp->height = r->height; if(c) resize(c, rp->x, rp->y, rp->width - (2*c->bw), rp->height - (2*c->bw), False); r->x += c ? WIDTH(c) : rp->width; r->width -= c ? WIDTH(c) : rp->width; pos = 1; break; case 1: /* top */ rp->x = r->x; rp->y = r->y; rp->width = r->width; rp->height = r->height * f; if(c) resize(c, rp->x, rp->y, rp->width - (2*c->bw), rp->height - (2*c->bw), False); r->y += c ? HEIGHT(c) : rp->height; r->height -= c ? HEIGHT(c) : rp->height; pos = 2; break; case 2: /* right */ rp->x = r->x + r->width * (1 - f); rp->y = r->y; rp->width = r->width * f; rp->height = r->height; if(c) resize(c, rp->x, rp->y, rp->width - (2*c->bw), rp->height - (2*c->bw), False); r->width -= c ? WIDTH(c) : rp->width; pos = 3; break; case 3: /* bottom */ rp->x = r->x; rp->y = r->y + r->height * (1 -f); rp->width = r->width; rp->height = r->height * f; if(c) resize(c, rp->x, rp->y, rp->width - (2*c->bw), rp->height - (2*c->bw), False); r->height -= c ? HEIGHT(c) : rp->height; pos = 0; break; } if(fact == 1) pos = 1; /* reset to initial value */ }