- for(i = 0, c = mc = nexttiled(clients); c; c = nexttiled(c->next)) {
- if(i == 0) { /* master */
- nw = mw - 2 * c->border;
- nh = MH - 2 * c->border;
- }
- else { /* tile window */
- if(i == 1) {
- ny = TY;
- nx = TX;
- nw = TW - 2 * c->border;
- }
- if(i + 1 == n) /* remainder */
- nh = (TY + TH) - ny - 2 * c->border;
- else
- nh = th - 2 * c->border;
- }
- resize(c, nx, ny, nw, nh, RESIZEHINTS);
- if((RESIZEHINTS) && ((c->h < bh) || (c->h > nh) || (c->w < bh) || (c->w > nw)))
- /* client doesn't accept size constraints */
- resize(c, nx, ny, nw, nh, False);
- if(n > 1 && th != TH)
- ny = c->y + c->h + 2 * c->border;
- i++;
+ for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
+ if(i + 1 == n) /* remainder */
+ tileresize(c, x, ty, (tx + tw) - x - 2 * c->border, th - 2 * c->border);
+ else
+ tileresize(c, x, ty, w - 2 * c->border, th - 2 * c->border);
+ if(w != tw)
+ x = c->x + c->w + 2 * c->border;
+ }
+}
+
+Client *
+tilemaster(unsigned int n) {
+ Client *c = nexttiled(clients);
+
+ if(n == 1)
+ tileresize(c, mox, moy, mow - 2 * c->border, moh - 2 * c->border);
+ else
+ tileresize(c, mx, my, mw - 2 * c->border, mh - 2 * c->border);
+ return c;
+}
+
+void
+tileresize(Client *c, int x, int y, int w, int h) {
+ resize(c, x, y, w, h, RESIZEHINTS);
+ if((RESIZEHINTS) && ((c->h < bh) || (c->h > h) || (c->w < bh) || (c->w > w)))
+ /* client doesn't accept size constraints */
+ resize(c, x, y, w, h, False);
+}
+
+void
+tilev(void) {
+ int y, h;
+ unsigned int i, n = counttiled();
+ Client *c;
+
+ if(n == 0)
+ return;
+ c = tilemaster(n);
+ if(--n == 0)
+ return;
+
+ y = ty;
+ h = th / n;
+ if(h < bh)
+ h = th;
+
+ for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
+ if(i + 1 == n) /* remainder */
+ tileresize(c, tx, y, tw - 2 * c->border, (ty + th) - y - 2 * c->border);
+ else
+ tileresize(c, tx, y, tw - 2 * c->border, h - 2 * c->border);
+ if(h != th)
+ y = c->y + c->h + 2 * c->border;