Hi there,

I have adapted the nmaster ntile layout for the current dwm 
hg tip. Maybe it could be useful for someone else.

You should modify config.h to include (after setting RESIZEHINTS):

#define NMASTER 1
#include "nmaster.c"

Add a new "ntile" layout

        Layout layouts[] = {
                ...
                { "-|=" , ntile },
                ...
        };

and, finally, two new keybinds:

        { MODKEY|ShiftMask , XK_j , setnmaster , "+1" } ,
        { MODKEY|ShiftMask , XK_k , setnmaster , "-1" } ,

I have adapted neither cpt nor tilecols. Of course, thanks for your patch 
pancake.

Kind regards,
Nibble
int nmaster = NMASTER;

void
ntile(void) {
	unsigned int i, n = counttiled(), lnx, lny, lnw, lnh, lmw, lmh, lth;
	Client *c;

	/* window geoms */
	lmh = (n <= nmaster) ? mh / (n > 0 ? n : 1) : mh / nmaster;
	lmw = (n <= nmaster) ? ww : mw;
	lth = (n > nmaster) ? th / (n - nmaster) : 0;
	if(n > nmaster && lth < bh)
		lth = th;

	lnx = mx;
	lny = my;

	for(i = 0, c = nexttiled(clients); c; c = nexttiled(c->next), i++) {
		if(i < nmaster) { /* master */
			lny = my + i * lmh;
			lnw = lmw - 2 * c->bw;
			lnh = lmh;
			if(i + 1 == (n < nmaster ? n : nmaster)) /* remainder */
				lnh = mh - 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 != wh)
			lny += lnh + 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();
}

Reply via email to