Hi,
I've modified Michael Elkins' elegant ntile layout implementation for use
with hg tip (any bugs are probably due to me).
To use it, save the attached ntile.c in your dwm folder, add
| #define NMASTER 1 /* number of clients in master area */
| #include "ntile.c"
before the layouts[] definition, and add ntile to the latter.
You can then use something like
| { MODKEY|ShiftMask, XK_h, setnmaster, {.i = -1} },
| { MODKEY|ShiftMask, XK_n, setnmaster, {.i = 0} } /* reset */,
| { MODKEY|ShiftMask, XK_l, setnmaster, {.i = +1} },
in your keys[] definition.
Regards,
Peter
static int nmaster = NMASTER;
static void
setnmaster(const Arg *arg) {
int n;
if(arg->i) {
n = nmaster + arg->i;
if(n < 1 || wh / n <= 2 * borderpx)
return;
nmaster = n;
}
else
nmaster = NMASTER;
arrange();
}
static Client *
ntilecol(Client* c, uint n, int x, int y, int w, int h) {
uint i, d;
for(i = 0; c && i < n; c = nexttiled(c->next), ++i) {
resize(c, x, y, w - 2 * c->bw, h / (n - i) - 2 * c->bw, True);
d = c->h + 2 * c->bw;
y += d;
h -= d;
}
return c;
}
static void
ntile(void) {
Client *c;
uint n, mw;
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next), ++n);
c = nexttiled(clients);
if(n <= nmaster)
ntilecol(c, n, wx, wy, ww, wh);
else {
mw = mfact * ww;
ntilecol(ntilecol(c, nmaster, wx, wy, mw, wh), n - nmaster, wx + mw, wy, ww - mw, wh);
}
}