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