/* ntile/nmaster layout for dwm-4.6 */ #if 0 Type this into your config.h /* ntile - nmaster */ extern void ntile(void); void incnmaster(const char *arg); Layout layouts[] = { { "-|=", ntile }, /* first entry is default */ .. { MODKEY|ShiftMask, XK_j, incnmaster, "+1"}, \ { MODKEY|ShiftMask, XK_k, incnmaster, "-1"}, \ #endif #include "dwm.h" #define NMASTER 1 #define BORDERPX 1 #define RESIZEHINTS False extern Client *clients; extern Client *sel; extern double mwfact; extern int screen, sx, sy, sw, sh, wax, way, waw, wah; extern unsigned int bh, bpos; int nmaster = NMASTER; void ntile(void) { unsigned int i, n, nx, ny, nw, nh, mw, mh, th; Client *c; for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) n++; /* window geoms */ mh = (n <= nmaster) ? wah / (n > 0 ? n : 1) : wah / nmaster; mw = (n <= nmaster) ? waw : mwfact * waw; th = (n > nmaster) ? wah / (n - nmaster) : 0; if(n > nmaster && th < bh) th = wah; nx = wax; ny = way; for(i = 0, c = nexttiled(clients); c; c = nexttiled(c->next), i++) { c->ismax = False; if(i < nmaster) { /* master */ ny = way + i * mh; nw = mw - 2 * c->border; nh = mh; if(i + 1 == (n < nmaster ? n : nmaster)) /* remainder */ nh = wah - mh * i; nh -= 2 * c->border; } else { /* tile window */ if(i == nmaster) { ny = way; nx += mw; } nw = waw - mw - 2 * c->border; if(i + 1 == n) /* remainder */ nh = (way + wah) - ny - 2 * c->border; else nh = th - 2 * c->border; } resize(c, nx, ny, nw, nh, RESIZEHINTS); if(n > nmaster && th != wah) ny += nh + 2 * c->border; } } void incnmaster(const char *arg) { int i; if(!isarrange(ntile)) return; if(!arg) nmaster = NMASTER; else { i = atoi(arg); if((nmaster + i) < 1 || wah / (nmaster + i) <= 2 * BORDERPX) return; nmaster += i; } if(sel) arrange(); }