int nmaster = NMASTER; void ntilevv(void) { unsigned int i, n = counttiled(), lnx, lny, lnw, lnh, lmah, lmw, lmh, lth; Client *c; /* window geoms */ lmah = (n <= nmaster) ? moh : mh; lmh = (n <= nmaster) ? lmah / (n > 0 ? n : 1) : lmah / nmaster; lmw = (n <= nmaster) ? mow : mw; lth = (n > nmaster) ? th / (n - nmaster) : 0; for(i = 0, c = nexttiled(clients); c; c = nexttiled(c->next), i++) { if(i < nmaster) { /* master */ lnx = mx; lny = my + i * lmh; lnw = lmw - 2 * c->bw; lnh = lmh; if(i + 1 == (n < nmaster ? n : nmaster)) /* remainder */ lnh = lmah - lmh * i; lnh -= 2 * c->bw; } else { /* tile window */ if(i == nmaster) { lny = ty; lnx = tx; } lnw = tw - 2 * c->bw; if(i + 1 == n) /* remainder */ lnh = (ty + th) - lny; else lnh = lth; lnh -= 2 * c->bw; } tileresize(c, lnx, lny, lnw, lnh); if(n > nmaster && lth != th) lny += lnh + 2 * c->bw; } } void ntilevh(void) { unsigned int i, n = counttiled(), lnx, lny, lnw, lnh, lmah, lmw, lmh, ltw; Client *c; /* window geoms */ lmah = (n <= nmaster) ? moh : mh; lmh = (n <= nmaster) ? lmah / (n > 0 ? n : 1) : lmah / nmaster; lmw = (n <= nmaster) ? mow : mw; ltw = (n > nmaster) ? tw / (n - nmaster) : 0; for(i = 0, c = nexttiled(clients); c; c = nexttiled(c->next), i++) { if(i < nmaster) { /* master */ lnx = mx; lny = my + i * lmh; lnw = lmw - 2 * c->bw; lnh = lmh; if(i + 1 == (n < nmaster ? n : nmaster)) /* remainder */ lnh = lmah - lmh * i; lnh -= 2 * c->bw; } else { /* tile window */ if(i == nmaster) { lny = ty; lnx = tx; } lnh = th - 2 * c->bw; if(i + 1 == n) /* remainder */ lnw = (tx + tw) - lnx; else lnw = ltw; lnw -= 2 * c->bw; } tileresize(c, lnx, lny, lnw, lnh); if(n > nmaster && ltw != tw) lnx += lnw + 2 * c->bw; } } void ntilehv(void) { unsigned int i, n = counttiled(), lnx, lny, lnw, lnh, lmaw, lmw, lmh, lth; Client *c; /* window geoms */ lmh = (n <= nmaster) ? moh : mh; lmaw = (n <= nmaster) ? mow : mw; lmw = (n <= nmaster) ? lmaw / (n > 0 ? n : 1) : lmaw / nmaster; lth = (n > nmaster) ? th / (n - nmaster) : 0; for(i = 0, c = nexttiled(clients); c; c = nexttiled(c->next), i++) { if(i < nmaster) { /* master */ lnx = mx + i * lmw; lny = my; lnw = lmw; lnh = lmh - 2 * c->bw; if(i + 1 == (n < nmaster ? n : nmaster)) /* remainder */ lnw = lmaw - lmw * i; lnw -= 2 * c->bw; } else { /* tile window */ if(i == nmaster) { lny = ty; lnx = tx; } lnw = tw - 2 * c->bw; if(i + 1 == n) /* remainder */ lnh = (ty + th) - lny; else lnh = lth; lnh -= 2 * c->bw; } tileresize(c, lnx, lny, lnw, lnh); if(n > nmaster && lth != th) lny += lnh + 2 * c->bw; } } void ntilehh(void) { unsigned int i, n = counttiled(), lnx, lny, lnw, lnh, lmaw, lmw, lmh, ltw; Client *c; /* window geoms */ lmh = (n <= nmaster) ? moh : mh; lmaw = (n <= nmaster) ? mow : mw; lmw = (n <= nmaster) ? lmaw / (n > 0 ? n : 1) : lmaw / nmaster; ltw = (n > nmaster) ? tw / (n - nmaster) : 0; for(i = 0, c = nexttiled(clients); c; c = nexttiled(c->next), i++) { if(i < nmaster) { /* master */ lnx = mx + i * lmw; lny = my; lnw = lmw; lnh = lmh - 2 * c->bw; if(i + 1 == (n < nmaster ? n : nmaster)) /* remainder */ lnw = lmaw - lmw * i; lnw -= 2 * c->bw; } else { /* tile window */ if(i == nmaster) { lny = ty; lnx = tx; } lnh = th - 2 * c->bw; if(i + 1 == n) /* remainder */ lnw = (tx + tw) - lnx; else lnw = ltw; lnw -= 2 * c->bw; } tileresize(c, lnx, lny, lnw, lnh); if(n > nmaster && ltw != tw) lnx += lnw + 2 * c->bw; } } void setnmaster(const char *arg) { int i; if(!arg) nmaster = NMASTER; else { i = atoi(arg); if((nmaster + i) < 1 || wh / (nmaster + i) <= 2 * BORDERPX) return; nmaster += i; } if(sel) arrange(); }