gjbianco avatar gjbianco committed e4b4076

cleaned up directory

Comments (0)

Files changed (29)

patches/border.diff

+diff -aur dwm-5.7.2/dwm.c dwm-new/dwm.c
+--- dwm-5.7.2/dwm.c	2009-09-27 15:20:23.000000000 -0400
++++ dwm-new/dwm.c	2010-03-27 17:46:51.305677828 -0400
+@@ -1128,7 +1128,7 @@
+ 		/* only fix client y-offset, if the client center might cover the bar */
+ 		c->y = MAX(c->y, ((c->mon->by == 0) && (c->x + (c->w / 2) >= c->mon->wx)
+ 		           && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my);
+-		c->bw = borderpx;
++		c->bw = 0;
+ 	}
+ 	wc.border_width = c->bw;
+ 	XConfigureWindow(dpy, w, CWBorderWidth, &wc);
+@@ -1600,6 +1600,7 @@
+ 	/* master */
+ 	c = nexttiled(m->clients);
+ 	mw = m->mfact * m->ww;
++	c->bw = (n > 1 ? borderpx : 0);
+ 	resize(c, m->wx, m->wy, (n == 1 ? m->ww : mw) - 2 * c->bw, m->wh - 2 * c->bw, False);
+ 	if(--n == 0)
+ 		return;
+@@ -1611,6 +1612,7 @@
+ 	if(h < bh)
+ 		h = m->wh;
+ 	for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
++		c->bw = borderpx;
+ 		resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n)
+ 		       ? m->wy + m->wh - y - 2 * c->bw : h - 2 * c->bw), False);
+ 		if(h != m->wh)

patches/dwm-5.7.2-attachaside.diff

+diff -r 9f79d36bd5e0 dwm.c
+--- a/dwm.c	Tue Sep 08 13:33:58 2009 +0100
++++ b/dwm.c	Tue Sep 15 14:19:26 2009 +0200
+@@ -153,6 +153,7 @@
+ static Bool applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact);
+ static void arrange(void);
+ static void attach(Client *c);
++static void attachaside(Client *c);
+ static void attachstack(Client *c);
+ static void buttonpress(XEvent *e);
+ static void checkotherwm(void);
+@@ -397,6 +398,17 @@
+ }
+ 
+ void
++attachaside(Client *c) {
++	Client *at = nexttiled(c->mon->clients);;
++	if(c->mon->sel == NULL || c->mon->sel->isfloating || !at) {
++		attach(c);
++		return;
++	}
++	c->next = at->next;
++	at->next = c;
++}
++
++void
+ attachstack(Client *c) {
+ 	c->snext = c->mon->stack;
+ 	c->mon->stack = c;
+@@ -1105,7 +1117,7 @@
+ 		c->isfloating = trans != None || c->isfixed;
+ 	if(c->isfloating)
+ 		XRaiseWindow(dpy, c->win);
+-	attach(c);
++	attachaside(c);
+ 	attachstack(c);
+ 	XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */
+ 	XMapWindow(dpy, c->win);

patches/dwm-5.7.2-onewinnoborder.diff

+diff -up dwm-5.7.2/dwm.c dwm-5.7.2-modified/dwm.c
+--- dwm-5.7.2/dwm.c	2009-09-27 20:20:23.000000000 +0100
++++ dwm-5.7.2-modified/dwm.c	2010-03-26 19:58:14.000000000 +0000
+@@ -394,10 +394,33 @@ arrange(Monitor *m) {
+ 
+ void
+ arrangemon(Monitor *m) {
++	Client *c;
++	XWindowChanges wc;
++	unsigned int n;
++
+ 	strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof m->ltsymbol);
+ 	if(m->lt[m->sellt]->arrange)
+ 		m->lt[m->sellt]->arrange(m);
+ 	restack(m);
++
++	/* rest of function is to hide a window's border when it's the only one on screen */
++	n = 0;
++	for(c = m->clients; c; c = c->next)
++		if(ISVISIBLE(c))
++			n++;
++	if (n != 0 && m->sel) { /* we don't care if there are no windows, or nothing is selected */
++		c = m->sel;
++		if (!m->showbar && (m->lt[m->sellt]->arrange == monocle || n == 1)) {
++			wc.border_width = 0;
++			XConfigureWindow(dpy, c->win, CWBorderWidth, &wc);
++			XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w + 2 * c->bw, c->h + 2 * c->bw);
++		}
++		else {
++			wc.border_width = c->bw;
++			XConfigureWindow(dpy, c->win, CWBorderWidth, &wc);
++			XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
++		}
++	}
+ }
+ 
+ void
+@@ -812,6 +835,10 @@ expose(XEvent *e) {
+ 
+ void
+ focus(Client *c) {
++	Client *mc;
++	XWindowChanges wc;
++	unsigned int n;
++	
+ 	if(!c || !ISVISIBLE(c))
+ 		for(c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);
+ 	if(selmon->sel)
+@@ -826,6 +853,23 @@ focus(Client *c) {
+ 		grabbuttons(c, True);
+ 		XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
+ 		XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
++
++		/* this bit is to hide a window's border when it's the only one on the screen */
++		n = 0;
++		for(mc = selmon->clients; mc; mc = mc->next)
++			if(ISVISIBLE(mc))
++				n++;
++		if (!selmon->showbar && (selmon->lt[selmon->sellt]->arrange == monocle || n == 1)) {
++			wc.border_width = 0;
++			XConfigureWindow(dpy, c->win, CWBorderWidth, &wc);
++			XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w + 2 * c->bw, c->h + 2 * c->bw);
++		}
++		else {
++			wc.border_width = c->bw;
++			XConfigureWindow(dpy, c->win, CWBorderWidth, &wc);
++			XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
++		}
++		
+ 	}
+ 	else
+ 		XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);

patches/dwm-5.8.2-bstack-alt.diff

+diff -up dwm-5.8.2-original/config.def.h dwm-5.8.2/config.def.h
+--- dwm-5.8.2-original/config.def.h	2010-06-04 06:39:15.000000000 -0400
++++ dwm-5.8.2/config.def.h	2010-07-07 14:56:15.000000000 -0400
+@@ -31,6 +31,8 @@ static const Layout layouts[] = {
+ 	{ "[]=",      tile },    /* first entry is default */
+ 	{ "><>",      NULL },    /* no layout function means floating behavior */
+ 	{ "[M]",      monocle },
++ 	{ "TTT",      bstack },
++ 	{ "===",      bstackhoriz },
+ };
+ 
+ /* key definitions */
+diff -up dwm-5.8.2-original/dwm.c dwm-5.8.2/dwm.c
+--- dwm-5.8.2-original/dwm.c	2010-06-04 06:39:15.000000000 -0400
++++ dwm-5.8.2/dwm.c	2010-07-07 15:03:16.000000000 -0400
+@@ -158,6 +158,8 @@ static void arrange(Monitor *m);
+ static void arrangemon(Monitor *m);
+ static void attach(Client *c);
+ static void attachstack(Client *c);
++static void bstack(Monitor *m);
++static void bstackhoriz(Monitor *m);
+ static void buttonpress(XEvent *e);
+ static void checkotherwm(void);
+ static void cleanup(void);
+@@ -1657,6 +1659,67 @@ tile(Monitor *m) {
+ 	if(h < bh)
+ 		h = m->wh;
+ 	for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
++		resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n)
++		       ? m->wy + m->wh - y - 2 * c->bw : h - 2 * c->bw), False);
++		if(h != m->wh)
++			y = c->y + HEIGHT(c);
++	}
++}
++
++static void
++bstack(Monitor *m) {
++	int x, y, h, w, mh;
++	unsigned int i, n;
++	Client *c;
++
++	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
++	if(n == 0)
++		return;
++	/* master */
++	c = nexttiled(m->clients);
++	mh = m->mfact * m->wh;
++	resize(c, m->wx, m->wy, m->ww - 2 * c->bw, (n == 1 ? m->wh : mh) - 2 * c->bw, False);
++	if(--n == 0)
++		return;
++	/* tile stack */
++	x = m->wx;
++	y = (m->wy + mh > c->y + c->h) ? c->y + c->h + 2 * c->bw : m->wy + mh;
++	w = m->ww / n;
++	h = (m->wy + mh > c->y + c->h) ? m->wy + m->wh - y : m->wh - mh;
++	if(w < bh)
++		w = m->ww;
++	for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
++		resize(c, x, y, /* remainder */ ((i + 1 == n)
++		       ? m->wx + m->ww - x - 2 * c->bw : w - 2 * c->bw), h - 2 * c->bw, False);
++		if(w != m->ww)
++			x = c->x + WIDTH(c);
++	}
++}
++
++static void
++bstackhoriz(Monitor *m) {
++	int x, y, h, w, mh;
++	unsigned int i, n;
++	Client *c;
++
++	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
++	if(n == 0)
++		return;
++	/* master */
++	c = nexttiled(m->clients);
++	mh = m->mfact * m->wh;
++	resize(c, m->wx, m->wy, m->ww - 2 * c->bw, (n == 1 ? m->wh : mh) - 2 * c->bw, False);
++	if(--n == 0)
++		return;
++	/* tile stack */
++	x = m->wx;
++	y = (m->wy + mh > c->y + c->h) ? c->y + c->h + 2 * c->bw : m->wy + mh;
++	w = m->ww;
++	h = (m->wy + mh > c->y + c->h) ? m->wy + m->wh - y : m->wh - mh;
++	h /= n;
++	if(h < bh)
++		h = m->wh;
++	for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
+ 		resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n)
+ 		       ? m->wy + m->wh - y - 2 * c->bw : h - 2 * c->bw), False);
+ 		if(h != m->wh)
+

patches/dwm-5.8.2-bstack.diff

+diff -NU5 -r dwm-5.8.2/bstack.c dwm-5.8.2-bstack/bstack.c
+--- dwm-5.8.2/bstack.c	1970-01-01 01:00:00.000000000 +0100
++++ dwm-5.8.2-bstack/bstack.c	2010-06-15 17:47:44.000000000 +0200
+@@ -0,0 +1,29 @@
++static void
++bstack(Monitor *m) {
++	int x, y, h, w, mh;
++	unsigned int i, n;
++	Client *c;
++
++	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
++	if(n == 0)
++		return;
++	/* master */
++	c = nexttiled(m->clients);
++	mh = m->mfact * m->wh;
++	resize(c, m->wx, m->wy, m->ww - 2 * c->bw, (n == 1 ? m->wh : mh) - 2 * c->bw, False);
++	if(--n == 0)
++		return;
++	/* tile stack */
++	x = m->wx;
++	y = (m->wy + mh > c->y + c->h) ? c->y + c->h + 2 * c->bw : m->wy + mh;
++	w = m->ww / n;
++	h = (m->wy + mh > c->y + c->h) ? m->wy + m->wh - y : m->wh - mh;
++	if(w < bh)
++		w = m->ww;
++	for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
++		resize(c, x, y, /* remainder */ ((i + 1 == n)
++		       ? m->wx + m->ww - x - 2 * c->bw : w - 2 * c->bw), h - 2 * c->bw, False);
++		if(w != m->ww)
++			x = c->x + WIDTH(c);
++	}
++}
+diff -NU5 -r dwm-5.8.2/bstackhoriz.c dwm-5.8.2-bstack/bstackhoriz.c
+--- dwm-5.8.2/bstackhoriz.c	1970-01-01 01:00:00.000000000 +0100
++++ dwm-5.8.2-bstack/bstackhoriz.c	2010-06-15 17:47:44.000000000 +0200
+@@ -0,0 +1,30 @@
++static void
++bstackhoriz(Monitor *m) {
++	int x, y, h, w, mh;
++	unsigned int i, n;
++	Client *c;
++
++	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
++	if(n == 0)
++		return;
++	/* master */
++	c = nexttiled(m->clients);
++	mh = m->mfact * m->wh;
++	resize(c, m->wx, m->wy, m->ww - 2 * c->bw, (n == 1 ? m->wh : mh) - 2 * c->bw, False);
++	if(--n == 0)
++		return;
++	/* tile stack */
++	x = m->wx;
++	y = (m->wy + mh > c->y + c->h) ? c->y + c->h + 2 * c->bw : m->wy + mh;
++	w = m->ww;
++	h = (m->wy + mh > c->y + c->h) ? m->wy + m->wh - y : m->wh - mh;
++	h /= n;
++	if(h < bh)
++		h = m->wh;
++	for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
++		resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n)
++		       ? m->wy + m->wh - y - 2 * c->bw : h - 2 * c->bw), False);
++		if(h != m->wh)
++			y = c->y + HEIGHT(c);
++	}
++}
+diff -NU5 -r dwm-5.8.2/config.def.h dwm-5.8.2-bstack/config.def.h
+--- dwm-5.8.2/config.def.h	2010-06-04 12:39:15.000000000 +0200
++++ dwm-5.8.2-bstack/config.def.h	2010-06-15 17:47:44.000000000 +0200
+@@ -29,1 +29,3 @@
++#include "bstack.c"
++#include "bstackhoriz.c"
+ static const Layout layouts[] = {
+@@ -34,5 +36,7 @@
++	{ "TTT",      bstack },
++	{ "===",      bstackhoriz },
+ };
+ 
+ /* key definitions */
+ #define MODKEY Mod1Mask
+ #define TAGKEYS(KEY,TAG) \

patches/dwm-5.8.2-pertag_without_bar.diff

+diff --git a/dwm.c b/dwm.c
+--- a/dwm.c
++++ b/dwm.c
+@@ -122,26 +122,6 @@ typedef struct {
+ 	void (*arrange)(Monitor *);
+ } Layout;
+ 
+-struct Monitor {
+-	char ltsymbol[16];
+-	float mfact;
+-	int num;
+-	int by;               /* bar geometry */
+-	int mx, my, mw, mh;   /* screen size */
+-	int wx, wy, ww, wh;   /* window area  */
+-	unsigned int seltags;
+-	unsigned int sellt;
+-	unsigned int tagset[2];
+-	Bool showbar;
+-	Bool topbar;
+-	Client *clients;
+-	Client *sel;
+-	Client *stack;
+-	Monitor *next;
+-	Window barwin;
+-	const Layout *lt[2];
+-};
+-
+ typedef struct {
+ 	const char *class;
+ 	const char *instance;
+@@ -278,6 +258,30 @@ static Window root;
+ /* configuration, allows nested code to access above variables */
+ #include "config.h"
+ 
++struct Monitor {
++	char ltsymbol[16];
++	float mfact;
++	int num;
++	int by;               /* bar geometry */
++	int mx, my, mw, mh;   /* screen size */
++	int wx, wy, ww, wh;   /* window area  */
++	unsigned int seltags;
++	unsigned int sellt;
++	unsigned int tagset[2];
++	Bool showbar;
++	Bool topbar;
++	Client *clients;
++	Client *sel;
++	Client *stack;
++	Monitor *next;
++	Window barwin;
++	const Layout *lt[2];
++	int curtag;
++	int prevtag;
++	const Layout *lts[LENGTH(tags) + 1];
++	double mfacts[LENGTH(tags) + 1];
++};
++
+ /* compile-time check if all tags fit into an unsigned int bit array. */
+ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
+ 
+@@ -609,6 +613,7 @@ configurerequest(XEvent *e) {
+ Monitor *
+ createmon(void) {
+ 	Monitor *m;
++	unsigned int i;
+ 
+ 	if(!(m = (Monitor *)calloc(1, sizeof(Monitor))))
+ 		die("fatal: could not malloc() %u bytes\n", sizeof(Monitor));
+@@ -619,6 +624,14 @@ createmon(void) {
+ 	m->lt[0] = &layouts[0];
+ 	m->lt[1] = &layouts[1 % LENGTH(layouts)];
+ 	strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
++
++	/* pertag init */
++	m->curtag = m->prevtag = 1;
++	for(i=0; i < LENGTH(tags) + 1 ; i++) {
++		m->mfacts[i] = mfact;
++		m->lts[i] = &layouts[0];
++	}
++
+ 	return m;
+ }
+ 
+@@ -1486,7 +1499,7 @@ setlayout(const Arg *arg) {
+ 	if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
+ 		selmon->sellt ^= 1;
+ 	if(arg && arg->v)
+-		selmon->lt[selmon->sellt] = (Layout *)arg->v;
++		selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag] = (Layout *)arg->v;
+ 	strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
+ 	if(selmon->sel)
+ 		arrange(selmon);
+@@ -1504,7 +1517,7 @@ setmfact(const Arg *arg) {
+ 	f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
+ 	if(f < 0.1 || f > 0.9)
+ 		return;
+-	selmon->mfact = f;
++	selmon->mfact = selmon->mfacts[selmon->curtag] = f;
+ 	arrange(selmon);
+ }
+ 
+@@ -1547,7 +1560,6 @@ setup(void) {
+ 	XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
+ 	if(!dc.font.set)
+ 		XSetFont(dpy, dc.gc, dc.font.xfont->fid);
+-	/* init bars */
+ 	updatebars();
+ 	updatestatus();
+ 	/* EWMH support per view */
+@@ -1678,12 +1690,25 @@ togglefloating(const Arg *arg) {
+ void
+ toggletag(const Arg *arg) {
+ 	unsigned int newtags;
++	unsigned int i;
+ 
+ 	if(!selmon->sel)
+ 		return;
+ 	newtags = selmon->sel->tags ^ (arg->ui & TAGMASK);
+ 	if(newtags) {
+ 		selmon->sel->tags = newtags;
++		if(newtags == ~0) {
++			selmon->prevtag = selmon->curtag;
++			selmon->curtag = 0;
++		}
++		if(!(newtags & 1 << (selmon->curtag - 1))) {
++			selmon->prevtag = selmon->curtag;
++			for (i=0; !(newtags & 1 << i); i++);
++			selmon->curtag = i + 1;
++		}
++		selmon->sel->tags = newtags;
++		selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag];
++		selmon->mfact = selmon->mfacts[selmon->curtag];
+ 		arrange(selmon);
+ 	}
+ }
+@@ -1950,11 +1975,27 @@ updatewmhints(Client *c) {
+ 
+ void
+ view(const Arg *arg) {
++	unsigned int i;
++
+ 	if((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
+ 		return;
+ 	selmon->seltags ^= 1; /* toggle sel tagset */
+-	if(arg->ui & TAGMASK)
++	if(arg->ui & TAGMASK) {
+ 		selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
++		selmon->prevtag = selmon->curtag;
++		if(arg->ui == ~0)
++			selmon->curtag = 0;
++		else {
++			for (i=0; !(arg->ui & 1 << i); i++);
++			selmon->curtag = i + 1;
++		}
++	} else {
++		selmon->prevtag= selmon->curtag ^ selmon->prevtag;
++		selmon->curtag^= selmon->prevtag;
++		selmon->prevtag= selmon->curtag ^ selmon->prevtag;
++	}
++	selmon->lt[selmon->sellt]= selmon->lts[selmon->curtag];
++	selmon->mfact = selmon->mfacts[selmon->curtag];
+ 	arrange(selmon);
+ }
+ 

patches/dwm-5.9-bstack-alt.diff

+diff -up dwm-5.8.2-original/config.def.h dwm-5.8.2/config.def.h
+--- dwm-5.8.2-original/config.def.h	2010-06-04 06:39:15.000000000 -0400
++++ dwm-5.8.2/config.def.h	2010-07-07 14:56:15.000000000 -0400
+@@ -31,6 +31,8 @@ static const Layout layouts[] = {
+ 	/* symbol     arrange function */
+ 	{ "[]=",      tile },    /* first entry is default */
+ 	{ "><>",      NULL },    /* no layout function means floating behavior */
+ 	{ "[M]",      monocle },
++ 	{ "TTT",      bstack },
++ 	{ "===",      bstackhoriz },
+ };
+
+ /* key definitions */
+ #define MODKEY Mod1Mask
+ #define TAGKEYS(KEY,TAG) \
+ };
+ 
+diff -up dwm-5.8.2-original/dwm.c dwm-5.8.2/dwm.c
+--- dwm-5.8.2-original/dwm.c	2010-06-04 06:39:15.000000000 -0400
++++ dwm-5.8.2/dwm.c	2010-07-07 15:03:16.000000000 -0400
+@@ -158,6 +158,8 @@ static void arrange(Monitor *m);
+ static void arrangemon(Monitor *m);
+ static void attach(Client *c);
+ static void attachstack(Client *c);
++static void bstack(Monitor *m);
++static void bstackhoriz(Monitor *m);
+ static void buttonpress(XEvent *e);
+ static void checkotherwm(void);
+ static void cleanup(void);
+@@ -1657,6 +1659,67 @@ tile(Monitor *m) {
+ 	if(h < bh)
+ 		h = m->wh;
+ 	for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
++		resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n)
++		       ? m->wy + m->wh - y - 2 * c->bw : h - 2 * c->bw), False);
++		if(h != m->wh)
++			y = c->y + HEIGHT(c);
++	}
++}
++
++static void
++bstack(Monitor *m) {
++	int x, y, h, w, mh;
++	unsigned int i, n;
++	Client *c;
++
++	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
++	if(n == 0)
++		return;
++	/* master */
++	c = nexttiled(m->clients);
++	mh = m->mfact * m->wh;
++	resize(c, m->wx, m->wy, m->ww - 2 * c->bw, (n == 1 ? m->wh : mh) - 2 * c->bw, False);
++	if(--n == 0)
++		return;
++	/* tile stack */
++	x = m->wx;
++	y = (m->wy + mh > c->y + c->h) ? c->y + c->h + 2 * c->bw : m->wy + mh;
++	w = m->ww / n;
++	h = (m->wy + mh > c->y + c->h) ? m->wy + m->wh - y : m->wh - mh;
++	if(w < bh)
++		w = m->ww;
++	for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
++		resize(c, x, y, /* remainder */ ((i + 1 == n)
++		       ? m->wx + m->ww - x - 2 * c->bw : w - 2 * c->bw), h - 2 * c->bw, False);
++		if(w != m->ww)
++			x = c->x + WIDTH(c);
++	}
++}
++
++static void
++bstackhoriz(Monitor *m) {
++	int x, y, h, w, mh;
++	unsigned int i, n;
++	Client *c;
++
++	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
++	if(n == 0)
++		return;
++	/* master */
++	c = nexttiled(m->clients);
++	mh = m->mfact * m->wh;
++	resize(c, m->wx, m->wy, m->ww - 2 * c->bw, (n == 1 ? m->wh : mh) - 2 * c->bw, False);
++	if(--n == 0)
++		return;
++	/* tile stack */
++	x = m->wx;
++	y = (m->wy + mh > c->y + c->h) ? c->y + c->h + 2 * c->bw : m->wy + mh;
++	w = m->ww;
++	h = (m->wy + mh > c->y + c->h) ? m->wy + m->wh - y : m->wh - mh;
++	h /= n;
++	if(h < bh)
++		h = m->wh;
++	for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
+ 		resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n)
+ 		       ? m->wy + m->wh - y - 2 * c->bw : h - 2 * c->bw), False);
+ 		if(h != m->wh)
+

patches/jokerboy/01-dwm-5.9-pertag2.diff

+--- a/dwm.c	2011-07-10 23:24:25.000000000 +0300
++++ b/dwm.c	2011-09-23 17:37:51.371405880 +0300
+@@ -124,7 +124,6 @@ typedef struct {
+ 
+ struct Monitor {
+ 	char ltsymbol[16];
+-	float mfact;
+ 	int num;
+ 	int by;               /* bar geometry */
+ 	int mx, my, mw, mh;   /* screen size */
+@@ -140,9 +139,21 @@ struct Monitor {
+ 	Monitor *next;
+ 	Window barwin;
+ 	const Layout *lt[2];
++	int curtag;
++	int prevtag;
++	const Layout **lts;
++	double *mfacts;
++	int *nmasters;
+ };
+ 
+ typedef struct {
++	const char *name;
++	const Layout *layout;
++	float mfact;
++	int nmaster;
++} Tag;
++
++typedef struct {
+ 	const char *class;
+ 	const char *instance;
+ 	const char *title;
+@@ -244,6 +255,9 @@ static int xerror(Display *dpy, XErrorEv
+ static int xerrordummy(Display *dpy, XErrorEvent *ee);
+ static int xerrorstart(Display *dpy, XErrorEvent *ee);
+ static void zoom(const Arg *arg);
++static void incnmaster(const Arg *arg);
++static void ntile(Monitor *m);
++static void nbstack(Monitor *m);
+ 
+ /* variables */
+ static const char broken[] = "broken";
+@@ -434,7 +448,7 @@ buttonpress(XEvent *e) {
+ 	if(ev->window == selmon->barwin) {
+ 		i = x = 0;
+ 		do {
+-			x += TEXTW(tags[i]);
++			x += TEXTW(tags[i].name);
+ 		} while(ev->x >= x && ++i < LENGTH(tags));
+ 		if(i < LENGTH(tags)) {
+ 			click = ClkTagBar;
+@@ -506,6 +520,9 @@ cleanupmon(Monitor *mon) {
+ 	}
+ 	XUnmapWindow(dpy, mon->barwin);
+ 	XDestroyWindow(dpy, mon->barwin);
++	free(mon->mfacts);
++	free(mon->nmasters);
++	free(mon->lts);
+ 	free(mon);
+ }
+ 
+@@ -651,16 +668,31 @@ configurerequest(XEvent *e) {
+ Monitor *
+ createmon(void) {
+ 	Monitor *m;
++	int i, numtags = LENGTH(tags) + 1;
+ 
+ 	if(!(m = (Monitor *)calloc(1, sizeof(Monitor))))
+ 		die("fatal: could not malloc() %u bytes\n", sizeof(Monitor));
++	if(!(m->mfacts = calloc(numtags, sizeof(double))))
++		die("fatal: could not malloc() %u bytes\n", sizeof(double) * numtags);
++	if(!(m->nmasters = calloc(numtags, sizeof(int))))
++		die("fatal: could not malloc() %u bytes\n", sizeof(int) * numtags);
++	if(!(m->lts = calloc(numtags, sizeof(Layout *))))
++		die("fatal: could not malloc() %u bytes\n", sizeof(Layout *) * numtags);
+ 	m->tagset[0] = m->tagset[1] = 1;
+-	m->mfact = mfact;
++	m->mfacts[0] = mfact;
++	m->nmasters[0] = nmaster;
++	m->lts[0] = &layouts[0];
+ 	m->showbar = showbar;
+ 	m->topbar = topbar;
+-	m->lt[0] = &layouts[0];
++	m->curtag = m->prevtag = 1;
++	for(i = 1; i < numtags; i++) {
++		m->mfacts[i] = tags[i - 1].mfact < 0 ? mfact : tags[i - 1].mfact;
++		m->nmasters[i] = tags[i - 1].nmaster < 0 ? nmaster : tags[i - 1].nmaster;
++		m->lts[i] = tags[i - 1].layout;
++	}
++	m->lt[0] = m->lts[m->curtag];
+ 	m->lt[1] = &layouts[1 % LENGTH(layouts)];
+-	strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
++	strncpy(m->ltsymbol, m->lt[0]->symbol, sizeof m->ltsymbol);
+ 	return m;
+ }
+ 
+@@ -735,9 +767,9 @@ drawbar(Monitor *m) {
+ 	}
+ 	dc.x = 0;
+ 	for(i = 0; i < LENGTH(tags); i++) {
+-		dc.w = TEXTW(tags[i]);
++		dc.w = TEXTW(tags[i].name);
+ 		col = m->tagset[m->seltags] & 1 << i ? dc.sel : dc.norm;
+-		drawtext(tags[i], col, urg & 1 << i);
++		drawtext(tags[i].name, col, urg & 1 << i);
+ 		drawsquare(m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
+ 		           occ & 1 << i, urg & 1 << i, col);
+ 		dc.x += dc.w;
+@@ -1498,7 +1530,7 @@ setlayout(const Arg *arg) {
+ 	if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
+ 		selmon->sellt ^= 1;
+ 	if(arg && arg->v)
+-		selmon->lt[selmon->sellt] = (Layout *)arg->v;
++		selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag] = (Layout *)arg->v;
+ 	strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
+ 	if(selmon->sel)
+ 		arrange(selmon);
+@@ -1513,10 +1545,10 @@ setmfact(const Arg *arg) {
+ 
+ 	if(!arg || !selmon->lt[selmon->sellt]->arrange)
+ 		return;
+-	f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
++	f = arg->f < 1.0 ? arg->f + selmon->mfacts[selmon->curtag] : arg->f - 1.0;
+ 	if(f < 0.1 || f > 0.9)
+ 		return;
+-	selmon->mfact = f;
++	selmon->mfacts[selmon->curtag] = f;
+ 	arrange(selmon);
+ }
+ 
+@@ -1650,7 +1682,7 @@ tile(Monitor *m) {
+ 		return;
+ 	/* master */
+ 	c = nexttiled(m->clients);
+-	mw = m->mfact * m->ww;
++	mw = m->mfacts[m->curtag] * m->ww;
+ 	resize(c, m->wx, m->wy, (n == 1 ? m->ww : mw) - 2 * c->bw, m->wh - 2 * c->bw, False);
+ 	if(--n == 0)
+ 		return;
+@@ -1691,12 +1723,24 @@ togglefloating(const Arg *arg) {
+ void
+ toggletag(const Arg *arg) {
+ 	unsigned int newtags;
++	unsigned int i;
+ 
+ 	if(!selmon->sel)
+ 		return;
+ 	newtags = selmon->sel->tags ^ (arg->ui & TAGMASK);
+ 	if(newtags) {
+ 		selmon->sel->tags = newtags;
++		if(newtags == ~0) {
++			selmon->prevtag = selmon->curtag;
++			selmon->curtag = 0;
++		}
++		if(!(newtags & 1 << (selmon->curtag - 1))) {
++			selmon->prevtag = selmon->curtag;
++			for (i=0; !(newtags & 1 << i); i++);
++			selmon->curtag = i + 1;
++		}
++		selmon->sel->tags = newtags;
++		selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag];
+ 		arrange(selmon);
+ 	}
+ }
+@@ -1967,11 +2011,26 @@ updatewmhints(Client *c) {
+ 
+ void
+ view(const Arg *arg) {
++	unsigned int i;
++
+ 	if((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
+ 		return;
+ 	selmon->seltags ^= 1; /* toggle sel tagset */
+-	if(arg->ui & TAGMASK)
++	if(arg->ui & TAGMASK) {
+ 		selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
++		selmon->prevtag = selmon->curtag;
++		if(arg->ui == ~0)
++			selmon->curtag = 0;
++		else {
++			for (i=0; !(arg->ui & 1 << i); i++);
++			selmon->curtag = i + 1;
++		}
++	} else {
++		selmon->prevtag= selmon->curtag ^ selmon->prevtag;
++		selmon->curtag^= selmon->prevtag;
++		selmon->prevtag= selmon->curtag ^ selmon->prevtag;
++	}
++	selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag];
+ 	arrange(selmon);
+ }
+ 
+@@ -2049,6 +2108,56 @@ zoom(const Arg *arg) {
+ 	pop(c);
+ }
+ 
++void
++incnmaster(const Arg *arg) {
++	if(!arg || !selmon->lt[selmon->sellt]->arrange)
++		return;
++	selmon->nmasters[selmon->curtag] = MAX(selmon->nmasters[selmon->curtag] + arg->i, 1);
++	arrange(NULL);
++}
++
++void
++ntile(Monitor *m) {
++	unsigned int i, n, mw, mh, tw, th;
++	Client *c;
++
++	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
++	if(n == 0)
++		return;
++
++	mh = (n > m->nmasters[m->curtag]) ? m->wh / m->nmasters[m->curtag] : m->wh / n;
++	mw = (n > m->nmasters[m->curtag]) ? m->ww * m->mfacts[m->curtag] : m->ww;
++	th = (n > m->nmasters[m->curtag]) ? m->wh / (n - m->nmasters[m->curtag]) : 0;
++	tw = m->ww - mw;
++
++	for(i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
++		if(i < m->nmasters[m->curtag])
++			resize(c, m->wx, m->wy + (i*mh), mw - (2*c->bw), mh - (2*c->bw), False);
++		else
++			resize(c, m->wx + mw, m->wy + ((i - m->nmasters[m->curtag])*th), tw - (2*c->bw), th - (2*c->bw), False);
++}
++
++void
++nbstack(Monitor *m) {
++	unsigned int i, n, mw, mh, tw, th;
++	Client *c;
++
++	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
++	if(n == 0)
++		return;
++
++	mw = (n > m->nmasters[m->curtag]) ? m->ww / m->nmasters[m->curtag] : m->ww / n;
++	mh = (n > m->nmasters[m->curtag]) ? m->wh * m->mfacts[m->curtag] : m->wh;
++	tw = (n > m->nmasters[m->curtag]) ? m->ww / (n - m->nmasters[m->curtag]) : 0;
++	th = m->wh - mh;
++
++	for(i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
++		if(i < m->nmasters[m->curtag])
++			resize(c, m->wx + (i*mw), m->wy, mw - (2*c->bw), mh - (2*c->bw), False);
++		else
++			resize(c, m->wx + ((i - m->nmasters[m->curtag])*tw), m->wy + mh, tw - (2*c->bw), th - (2*c->bw), False);
++}
++
+ int
+ main(int argc, char *argv[]) {
+ 	if(argc == 2 && !strcmp("-v", argv[1]))

patches/jokerboy/02-dwm-5.9-push.diff

+--- a/dwm.c	2011-09-23 18:59:20.857712613 +0300
++++ b/dwm.c	2011-09-23 18:59:27.482713028 +0300
+@@ -258,6 +258,9 @@ static void zoom(const Arg *arg);
+ static void incnmaster(const Arg *arg);
+ static void ntile(Monitor *m);
+ static void nbstack(Monitor *m);
++static Client *prevtiled(Client *c);
++static void pushup(const Arg *arg);
++static void pushdown(const Arg *arg);
+ 
+ /* variables */
+ static const char broken[] = "broken";
+@@ -2158,6 +2161,65 @@ nbstack(Monitor *m) {
+ 			resize(c, m->wx + ((i - m->nmasters[m->curtag])*tw), m->wy + mh, tw - (2*c->bw), th - (2*c->bw), False);
+ }
+ 
++Client *
++prevtiled(Client *c) {
++	Client *p, *r;
++
++	for(p = selmon->clients, r = NULL; p && p != c; p = p->next)
++		if(!p->isfloating && ISVISIBLE(p))
++			r = p;
++	return r;
++}
++
++void
++pushup(const Arg *arg) {
++	Client *sel = selmon->sel;
++	Client *c;
++
++	if(!sel || sel->isfloating)
++		return;
++	if((c = prevtiled(sel))) {
++		/* attach before c */
++		detach(sel);
++		sel->next = c;
++		if(selmon->clients == c)
++			selmon->clients = sel;
++		else {
++			for(c = selmon->clients; c->next != sel->next; c = c->next);
++			c->next = sel;
++		}
++	} else {
++		/* move to the end */
++		for(c = sel; c->next; c = c->next);
++		detach(sel);
++		sel->next = NULL;
++		c->next = sel;
++	}
++	focus(sel);
++	arrange(selmon);
++}
++
++void
++pushdown(const Arg *arg) {
++	Client *sel = selmon->sel;
++	Client *c;
++
++	if(!sel || sel->isfloating)
++		return;
++	if((c = nexttiled(sel->next))) {
++		/* attach after c */
++		detach(sel);
++		sel->next = c->next;
++		c->next = sel;
++	} else {
++		/* move to the front */
++		detach(sel);
++		attach(sel);
++	}
++	focus(sel);
++	arrange(selmon);
++}
++
+ int
+ main(int argc, char *argv[]) {
+ 	if(argc == 2 && !strcmp("-v", argv[1]))

patches/jokerboy/03-dwm-5.9-cycle.diff

+--- a/dwm.c	2011-09-23 19:03:04.217726620 +0300
++++ b/dwm.c	2011-09-23 19:03:10.745727034 +0300
+@@ -261,6 +261,9 @@ static void nbstack(Monitor *m);
+ static Client *prevtiled(Client *c);
+ static void pushup(const Arg *arg);
+ static void pushdown(const Arg *arg);
++static void cycle(const Arg *arg);
++static int shifttag(int dist);
++static void tagcycle(const Arg *arg);
+ 
+ /* variables */
+ static const char broken[] = "broken";
+@@ -2221,6 +2224,42 @@ pushdown(const Arg *arg) {
+ }
+ 
+ int
++shifttag(int dist) {
++	int i, curtags;
++	int seltag = 0;
++	int numtags = LENGTH(tags);
++
++	curtags = selmon->tagset[selmon->seltags];
++	for(i = 0; i < LENGTH(tags); i++) {
++		if((curtags & (1 << i)) != 0) {
++			seltag = i;
++			break;
++		}
++	}
++
++	seltag += dist;
++	if(seltag < 0)
++		seltag = numtags - (-seltag) % numtags;
++	else
++		seltag %= numtags;
++
++	return 1 << seltag;
++}
++
++void
++cycle(const Arg *arg) {
++	const Arg a = { .i = shifttag(arg->i) };
++	view(&a);
++}
++
++void
++tagcycle(const Arg *arg) {
++	const Arg a = { .i = shifttag(arg->i) };
++	tag(&a);
++	view(&a);
++}
++
++int
+ main(int argc, char *argv[]) {
+ 	if(argc == 2 && !strcmp("-v", argv[1]))
+ 		die("dwm-"VERSION", © 2006-2011 dwm engineers, see LICENSE for details\n");

patches/jokerboy/04-dwm-5.9-gaplessgrid.diff

+--- a/dwm.c	2011-09-23 19:04:11.011730815 +0300
++++ b/dwm.c	2011-09-23 19:04:29.010731946 +0300
+@@ -264,6 +264,7 @@ static void pushdown(const Arg *arg);
+ static void cycle(const Arg *arg);
+ static int shifttag(int dist);
+ static void tagcycle(const Arg *arg);
++static void gaplessgrid(Monitor *m);
+ 
+ /* variables */
+ static const char broken[] = "broken";
+@@ -2259,6 +2260,43 @@ tagcycle(const Arg *arg) {
+ 	view(&a);
+ }
+ 
++void
++gaplessgrid(Monitor *m) {
++	unsigned int n, cols, rows, cn, rn, i, cx, cy, cw, ch;
++	Client *c;
++
++	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next))
++		n++;
++	if(n == 0)
++		return;
++
++	/* grid dimensions */
++	for(rows = 0; rows <= n/2; rows++)
++		if(rows*rows >= n)
++			break;
++	if(n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
++		rows = 2;
++	cols = n/rows;
++
++	/* window geometries */
++	ch = rows ? m->wh / rows : m->wh;
++	cn = 0; /* current column number */
++	rn = 0; /* current row number */
++	for(i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) {
++		if(i/cols + 1 > rows - n%rows)
++			cols = n/rows + 1;
++		cw = cols ? m->ww / cols : m->ww;
++		cx = m->wx + cn*cw;
++		cy = m->wy + rn*ch;
++		resize(c, cx, cy, cw - 2 * c->bw, ch - 2 * c->bw, False);
++		cn++;
++		if(cn >= cols) {
++			cn = 0;
++			rn++;
++		}
++	}
++}
++
+ int
+ main(int argc, char *argv[]) {
+ 	if(argc == 2 && !strcmp("-v", argv[1]))

patches/jokerboy/05-dwm-5.9-gaps.diff

+--- a/dwm.c	2011-09-23 19:05:08.380734413 +0300
++++ b/dwm.c	2011-09-23 19:05:19.417735106 +0300
+@@ -119,6 +119,7 @@ typedef struct {
+ 
+ typedef struct {
+ 	const char *symbol;
++	Bool addgaps;
+ 	void (*arrange)(Monitor *);
+ } Layout;
+ 
+@@ -491,7 +492,7 @@ checkotherwm(void) {
+ void
+ cleanup(void) {
+ 	Arg a = {.ui = ~0};
+-	Layout foo = { "", NULL };
++	Layout foo = { "", False, NULL };
+ 	Monitor *m;
+ 
+ 	view(&a);
+@@ -1356,11 +1357,12 @@ resize(Client *c, int x, int y, int w, i
+ void
+ resizeclient(Client *c, int x, int y, int w, int h) {
+ 	XWindowChanges wc;
++	unsigned int gap = c->isfloating ? 0 : c->mon->lt[c->mon->sellt]->addgaps ? gappx : 0;
+ 
+-	c->oldx = c->x; c->x = wc.x = x;
+-	c->oldy = c->y; c->y = wc.y = y;
+-	c->oldw = c->w; c->w = wc.width = w;
+-	c->oldh = c->h; c->h = wc.height = h;
++	c->oldx = c->x; c->x = wc.x = x + gap;
++	c->oldy = c->y; c->y = wc.y = y + gap;
++	c->oldw = c->w; c->w = wc.width = w - (gap ? (x + w + (c->bw * 2) == c->mon->mx + c->mon->mw ? 2 : 1) * gap : 0);
++	c->oldh = c->h; c->h = wc.height = h - (gap ? (y + h + (c->bw * 2) == c->mon->my + c->mon->mh ? 2 : 1) * gap : 0);
+ 	wc.border_width = c->bw;
+ 	XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
+ 	configure(c);

patches/jokerboy/06-dwm-5.9-pidgin.diff

+--- a/dwm.c	2011-09-24 20:45:22.085040717 +0300
++++ b/dwm.c	2011-09-24 20:47:41.007049432 +0300
+@@ -266,6 +266,7 @@ static void cycle(const Arg *arg);
+ static int shifttag(int dist);
+ static void tagcycle(const Arg *arg);
+ static void gaplessgrid(Monitor *m);
++static void pidgin(Monitor *m);
+ 
+ /* variables */
+ static const char broken[] = "broken";
+@@ -2298,6 +2299,61 @@ gaplessgrid(Monitor *m) {
+ 		}
+ 	}
+ }
++
++void
++pidgin(Monitor *m) {
++	unsigned int n, cols, rows, cn, rn, i, cx, cy, cw, ch, wx, ww;
++	Client *c, *bl = NULL;
++
++	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++)
++		if(strstr(c->name, "Buddy List"))
++			bl = c;
++	if(n == 0)
++		return;
++
++	/* buddy list */
++	if(bl) {
++		wx = m->mfacts[m->curtag] * m->ww;
++		ww = m->ww - wx;
++		resize(bl, m->wx, m->wy, wx - 2 * bl->bw, m->wh - 2 * bl->bw, False);
++		if(--n == 0)
++			return;
++	}
++	else {
++		wx = m->wx;
++		ww = m->ww;
++	}
++
++	/* grid dimensions */
++	for(cols = 0; cols <= n/2; cols++)
++		if(cols*cols >= n)
++			break;
++	if(n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
++		cols = 2;
++	rows = n/cols;
++
++	/* window geometries */
++	cw = cols ? ww / cols : ww;
++	cn = 0; /* current column number */
++	rn = 0; /* current row number */
++	for(i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) {
++		if(c == bl) {
++			--i;
++			continue;
++		}
++		if(i/rows + 1 > cols - n%cols)
++			rows = n/cols + 1;
++		ch = rows ? m->wh / rows : m->wh;
++		cx = wx + cn*cw;
++		cy = m->wy + rn*ch;
++		resize(c, cx, cy, cw - 2 * c->bw, ch - 2 * c->bw, False);
++		rn++;
++		if(rn >= rows) {
++			rn = 0;
++			cn++;
++		}
++	}
++}
+ 
+ int
+ main(int argc, char *argv[]) {

patches/jokerboy/07-dwm-5.9-monocle_count.diff

+--- a/dwm.c	2011-06-05 10:14:20.931000085 +0300
++++ b/dwm.c	2011-06-05 10:14:26.312000262 +0300
+@@ -767,6 +767,8 @@ drawbar(Monitor *m) {
+ 	int x;
+ 	unsigned int i, occ = 0, urg = 0;
+ 	unsigned long *col;
++	unsigned int a= 0, s= 0;
++	char posbuf[10];
+ 	Client *c;
+ 
+ 	for(c = m->clients; c; c = c->next) {
+@@ -787,6 +789,17 @@ drawbar(Monitor *m) {
+ 	drawtext(m->ltsymbol, dc.norm, False);
+ 	dc.x += dc.w;
+ 	x = dc.x;
++	if(m->lt[m->sellt]->arrange == monocle){
++		for(c= nexttiled(m->clients), a= 0, s= 0; c; c= nexttiled(c->next), a++)
++			if(c == m->stack)
++				s= a;
++		if(!s && a)
++			s= a;
++		snprintf(posbuf, LENGTH(posbuf), "[%d/%d]", s, a);
++		dc.w= TEXTW(posbuf);
++		drawtext(posbuf, dc.norm, False);
++		x= dc.x + dc.w;
++	}
+ 	if(m == selmon) { /* status is only drawn on selected monitor */
+ 		dc.w = TEXTW(stext);
+ 		dc.x = m->ww - dc.w;
+@@ -1226,8 +1239,6 @@ monocle(Monitor *m) {
+ 	for(c = m->clients; c; c = c->next)
+ 		if(ISVISIBLE(c))
+ 			n++;
+-	if(n > 0) /* override layout symbol */
+-		snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
+ 	for(c = nexttiled(m->clients); c; c = nexttiled(c->next))
+ 		resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, False);
+ }

patches/jokerboy/08-dwm-5.9-monocle_no_borders.diff

+--- a/dwm.c	2011-09-23 17:49:22.353449228 +0300
++++ b/dwm.c	2011-09-23 17:50:14.080452474 +0300
+@@ -1240,7 +1240,7 @@ monocle(Monitor *m) {
+ 		if(ISVISIBLE(c))
+ 			n++;
+ 	for(c = nexttiled(m->clients); c; c = nexttiled(c->next))
+-		resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, False);
++		resize(c, m->wx - c->bw, m->wy - c->bw, m->ww, m->wh, False);
+ }
+ 
+ void

patches/jokerboy/09-dwm-5.9-focusonclick.diff

+--- a/dwm.c	2011-07-10 22:12:16.720000000 +0300
++++ b/dwm.c	2011-07-10 22:15:17.964000003 +0300
+@@ -880,15 +880,17 @@ enternotify(XEvent *e) {
+ 
+ 	if((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && ev->window != root)
+ 		return;
+-	c = wintoclient(ev->window);
+-	m = c ? c->mon : wintomon(ev->window);
+-	if(m != selmon) {
+-		unfocus(selmon->sel, True);
+-		selmon = m;
++	if(!focusonclick) {
++		c = wintoclient(ev->window);
++		m = c ? c->mon : wintomon(ev->window);
++		if(m != selmon) {
++			unfocus(selmon->sel, True);
++			selmon = m;
++		}
++		else if(!c || c == selmon->sel)
++			return;
++		focus(c);
+ 	}
+-	else if(!c || c == selmon->sel)
+-		return;
+-	focus(c);
+ }
+ 
+ void

patches/jokerboy/10-dwm-5.9-viewontag.diff

+--- a/dwm.c	2011-09-23 19:09:24.807750501 +0300
++++ b/dwm.c	2011-09-23 19:09:32.570750988 +0300
+@@ -1673,6 +1673,8 @@ tag(const Arg *arg) {
+ 	if(selmon->sel && arg->ui & TAGMASK) {
+ 		selmon->sel->tags = arg->ui & TAGMASK;
+ 		arrange(selmon);
++		if(viewontag)
++			view(arg);
+ 	}
+ }
+ 

patches/jokerboy/11-dwm-5.9-urgentcolors.diff

+--- a/dwm.c	2011-09-23 19:31:52.248835029 +0300
++++ b/dwm.c	2011-09-23 19:31:58.787835440 +0300
+@@ -99,6 +99,7 @@ typedef struct {
+ 	int x, y, w, h;
+ 	unsigned long norm[ColLast];
+ 	unsigned long sel[ColLast];
++	unsigned long urg[ColLast];
+ 	Drawable drawable;
+ 	GC gc;
+ 	struct {
+@@ -779,7 +780,7 @@ drawbar(Monitor *m) {
+ 	dc.x = 0;
+ 	for(i = 0; i < LENGTH(tags); i++) {
+ 		dc.w = TEXTW(tags[i].name);
+-		col = m->tagset[m->seltags] & 1 << i ? dc.sel : dc.norm;
++		col = urg & 1 << i ? dc.urg : m->tagset[m->seltags] & 1 << i ? dc.sel : dc.norm;
+ 		drawtext(tags[i].name, col, urg & 1 << i);
+ 		drawsquare(m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
+ 		           occ & 1 << i, urg & 1 << i, col);
+@@ -1611,6 +1612,9 @@ setup(void) {
+ 	dc.sel[ColBorder] = getcolor(selbordercolor);
+ 	dc.sel[ColBG] = getcolor(selbgcolor);
+ 	dc.sel[ColFG] = getcolor(selfgcolor);
++	dc.urg[ColBorder] = getcolor(urgbordercolor);
++	dc.urg[ColBG] = getcolor(urgbgcolor);
++	dc.urg[ColFG] = getcolor(urgfgcolor);
+ 	dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(dpy, screen), bh, DefaultDepth(dpy, screen));
+ 	dc.gc = XCreateGC(dpy, root, 0, NULL);
+ 	XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
+@@ -2024,8 +2028,11 @@ updatewmhints(Client *c) {
+ 			wmh->flags &= ~XUrgencyHint;
+ 			XSetWMHints(dpy, c->win, wmh);
+ 		}
+-		else
++		else {
+ 			c->isurgent = (wmh->flags & XUrgencyHint) ? True : False;
++			if(c->isurgent)
++				XSetWindowBorder(dpy, c->win, dc.urg[ColBorder]);
++		}
+ 		if(wmh->flags & InputHint)
+ 			c->neverfocus = !wmh->input;
+ 		else

patches/jokerboy/12-dwm-5.9-scratchpad.diff

+--- a/dwm.c	2011-09-24 20:49:33.736056506 +0300
++++ b/dwm.c	2011-09-24 20:49:43.642057129 +0300
+@@ -268,6 +268,7 @@ static int shifttag(int dist);
+ static void tagcycle(const Arg *arg);
+ static void gaplessgrid(Monitor *m);
+ static void pidgin(Monitor *m);
++static void togglescratch(const Arg *arg);
+ 
+ /* variables */
+ static const char broken[] = "broken";
+@@ -303,6 +304,8 @@ static Window root;
+ /* configuration, allows nested code to access above variables */
+ #include "config.h"
+ 
++static unsigned int scratchtag = 1 << LENGTH(tags);
++
+ /* compile-time check if all tags fit into an unsigned int bit array. */
+ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
+ 
+@@ -1192,6 +1195,14 @@ manage(Window w, XWindowAttributes *wa)
+ 		           && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my);
+ 		c->bw = borderpx;
+ 	}
++	if(!strcmp(c->name, scratchpadname)) {
++		c->mon->tagset[c->mon->seltags] |= c->tags = scratchtag;
++		c->isfloating = True;
++		c->x = (c->mon->mw - WIDTH(c)) / 2;
++		c->y = (c->mon->mh - HEIGHT(c)) / 2;
++	}
++	else
++		c->tags &= TAGMASK;
+ 	wc.border_width = c->bw;
+ 	XConfigureWindow(dpy, w, CWBorderWidth, &wc);
+ 	XSetWindowBorder(dpy, w, dc.norm[ColBorder]);
+@@ -2377,6 +2388,27 @@ pidgin(Monitor *m) {
+ 	}
+ }
+ 
++void
++togglescratch(const Arg *arg) {
++	Client *c = NULL;
++	unsigned int found = 0;
++
++	for(c = selmon->clients; c && !(found = c->tags & scratchtag); c = c->next);
++	if(!found) {
++		spawn(arg);
++		return;
++	}
++	unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag;
++	if(newtagset) {
++		selmon->tagset[selmon->seltags] = newtagset;
++		arrange(selmon);
++	}
++	if(ISVISIBLE(c)) {
++		focus(c);
++		restack(selmon);
++	}
++}
++
+ int
+ main(int argc, char *argv[]) {
+ 	if(argc == 2 && !strcmp("-v", argv[1]))

patches/jokerboy/12-dwm-5.9-scratchpad_stay.diff.old

+--- a/dwm.c	2011-07-13 15:22:15.643000102 +0300
++++ b/dwm.c	2011-07-13 15:31:05.427000103 +0300
+@@ -268,6 +268,7 @@ static void tagcycle(const Arg *arg);
+ static void gaplessgrid(Monitor *m);
+ static void bstack(Monitor *m);
+ static void pidgin(Monitor *m);
++static void togglescratch(const Arg *arg);
+ 
+ /* variables */
+ static const char broken[] = "broken";
+@@ -303,6 +304,8 @@ static Window root;
+ /* configuration, allows nested code to access above variables */
+ #include "config.h"
+ 
++static unsigned int scratchtag = 1 << LENGTH(tags);
++
+ /* compile-time check if all tags fit into an unsigned int bit array. */
+ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
+ 
+@@ -1192,6 +1195,14 @@ manage(Window w, XWindowAttributes *wa)
+ 		           && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my);
+ 		c->bw = borderpx;
+ 	}
++	if(!strcmp(c->name, scratchpadname)) {
++		c->mon->tagset[c->mon->seltags] |= c->tags = scratchtag;
++		c->isfloating = True;
++		c->x = (c->mon->mw - WIDTH(c)) / 2;
++		c->y = (c->mon->mh - HEIGHT(c)) / 2;
++	}
++	else
++		c->tags &= TAGMASK;
+ 	wc.border_width = c->bw;
+ 	XConfigureWindow(dpy, w, CWBorderWidth, &wc);
+ 	XSetWindowBorder(dpy, w, dc.norm[ColBorder]);
+@@ -2049,8 +2061,9 @@ void
+ view(const Arg *arg) {
+ 	unsigned int i;
+ 
+-	if((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
++	if((arg->ui & TAGMASK) == (selmon->tagset[selmon->seltags] & TAGMASK))
+ 		return;
++	unsigned int stag = (selmon->tagset[selmon->seltags] & scratchtag);
+ 	selmon->seltags ^= 1; /* toggle sel tagset */
+ 	if(arg->ui & TAGMASK) {
+ 		selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
+@@ -2067,6 +2080,7 @@ view(const Arg *arg) {
+ 		selmon->prevtag= selmon->curtag ^ selmon->prevtag;
+ 	}
+ 	selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag];
++	selmon->tagset[selmon->seltags] |= stag;
+ 	arrange(selmon);
+ }
+ 
+@@ -2394,6 +2408,27 @@ pidgin(Monitor *m) {
+ 	}
+ }
+ 
++void
++togglescratch(const Arg *arg) {
++	Client *c = NULL;
++	unsigned int found = 0;
++
++	for(c = selmon->clients; c && !(found = c->tags & scratchtag); c = c->next);
++	if(!found) {
++		spawn(arg);
++		return;
++	}
++	unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag;
++	if(newtagset) {
++		selmon->tagset[selmon->seltags] = newtagset;
++		arrange(selmon);
++	}
++	if(ISVISIBLE(c)) {
++		focus(c);
++		restack(selmon);
++	}
++}
++
+ int
+ main(int argc, char *argv[]) {
+ 	if(argc == 2 && !strcmp("-v", argv[1]))

patches/jokerboy/13-dwm-5.9-togglemax.diff

+--- a/dwm.c	2011-09-24 20:50:37.329060496 +0300
++++ b/dwm.c	2011-09-24 20:50:47.354061123 +0300
+@@ -269,6 +269,7 @@ static void tagcycle(const Arg *arg);
+ static void gaplessgrid(Monitor *m);
+ static void pidgin(Monitor *m);
+ static void togglescratch(const Arg *arg);
++static void togglemax(const Arg *arg);
+ 
+ /* variables */
+ static const char broken[] = "broken";
+@@ -2409,6 +2410,18 @@ togglescratch(const Arg *arg) {
+ 	}
+ }
+ 
++void
++togglemax(const Arg *arg) {
++	Client *c;
++	if(!(c = selmon->sel))
++		return;
++	Monitor *m = c->mon;
++	c->isfloating = !c->isfloating || c->isfixed;
++	if(c->isfloating)
++		resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, True);
++	arrange(selmon);
++}
++
+ int
+ main(int argc, char *argv[]) {
+ 	if(argc == 2 && !strcmp("-v", argv[1]))

patches/jokerboy/14-dwm-5.9-autoresize.diff

+--- a/dwm.c	2011-09-23 19:40:19.819866871 +0300
++++ b/dwm.c	2011-09-23 19:40:24.354867158 +0300
+@@ -88,7 +88,7 @@ struct Client {
+ 	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
+ 	int bw, oldbw;
+ 	unsigned int tags;
+-	Bool isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
++	Bool isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, needresize;
+ 	Client *next;
+ 	Client *snext;
+ 	Monitor *mon;
+@@ -662,6 +662,8 @@ configurerequest(XEvent *e) {
+ 				configure(c);
+ 			if(ISVISIBLE(c))
+ 				XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
++			else
++				c->needresize = True;
+ 		}
+ 		else
+ 			configure(c);
+@@ -1653,7 +1655,12 @@ showhide(Client *c) {
+ 	if(!c)
+ 		return;
+ 	if(ISVISIBLE(c)) { /* show clients top down */
+-		XMoveWindow(dpy, c->win, c->x, c->y);
++		if(c->needresize) {
++			c->needresize = False;
++			XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
++		} else {
++			XMoveWindow(dpy, c->win, c->x, c->y);
++		}
+ 		if((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen)
+ 			resize(c, c->x, c->y, c->w, c->h, False);
+ 		showhide(c->snext);

patches/jokerboy/15-dwm-5.9-fix_netactivewindow.diff

+--- a/dwm.c	2011-07-10 23:47:46.211000022 +0300
++++ b/dwm.c	2011-07-10 23:49:18.734000024 +0300
+@@ -587,10 +587,8 @@ clientmessage(XEvent *e) {
+ 	}
+ 	else if(cme->message_type == netatom[NetActiveWindow]) {
+ 		if(!ISVISIBLE(c)) {
+-			c->mon->seltags ^= 1;
+-			c->mon->tagset[c->mon->seltags] = c->tags;
++			c->isurgent = True;
+ 		}
+-		pop(c);
+ 	}
+ }
+ 

patches/jokerboy/16-dwm-5.9-increase_mfact_limit.diff

+--- a/dwm.c	2011-09-23 19:40:52.483868921 +0300
++++ b/dwm.c	2011-09-23 19:41:03.962869645 +0300
+@@ -1582,7 +1582,7 @@ setmfact(const Arg *arg) {
+ 	if(!arg || !selmon->lt[selmon->sellt]->arrange)
+ 		return;
+ 	f = arg->f < 1.0 ? arg->f + selmon->mfacts[selmon->curtag] : arg->f - 1.0;
+-	if(f < 0.1 || f > 0.9)
++	if(f < 0.05 || f > 0.95)
+ 		return;
+ 	selmon->mfacts[selmon->curtag] = f;
+ 	arrange(selmon);

patches/jokerboy/17-dwm-5.9-remember-tags.diff

+--- a/dwm.c	2011-09-23 19:41:30.659871314 +0300
++++ b/dwm.c	2011-09-23 19:41:37.259871726 +0300
+@@ -301,6 +301,7 @@ static Display *dpy;
+ static DC dc;
+ static Monitor *mons = NULL, *selmon = NULL;
+ static Window root;
++static Atom tagsatom;
+ 
+ /* configuration, allows nested code to access above variables */
+ #include "config.h"
+@@ -1170,8 +1171,18 @@ manage(Window w, XWindowAttributes *wa)
+ 		c->tags = t->tags;
+ 	}
+ 	else {
++		Atom atom;
++		int format;
++		unsigned long n, extra;
++		unsigned int *ptags;
+ 		c->mon = selmon;
+-		applyrules(c);
++		if(XGetWindowProperty(dpy, w, tagsatom, 0L, 1L, False, XA_CARDINAL,
++		  &atom, &format, &n, &extra, (unsigned char **)&ptags)==Success && n==1 && *ptags!=0)
++			c->tags = *ptags; /* override rule tags with memorized tags */
++		else {
++			applyrules(c);
++			XChangeProperty(dpy, w, tagsatom, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&c->tags, 1);
++		}
+ 	}
+ 	/* geometry */
+ 	c->x = c->oldx = wa->x;
+@@ -1613,6 +1624,7 @@ setup(void) {
+ 	netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
+ 	netatom[NetWMState] = XInternAtom(dpy, "_NET_WM_STATE", False);
+ 	netatom[NetWMFullscreen] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False);
++	tagsatom = XInternAtom(dpy, "_DWM_TAGS", False);
+ 	/* init cursors */
+ 	cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
+ 	cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
+@@ -1693,6 +1705,7 @@ void
+ tag(const Arg *arg) {
+ 	if(selmon->sel && arg->ui & TAGMASK) {
+ 		selmon->sel->tags = arg->ui & TAGMASK;
++		XChangeProperty(dpy, selmon->sel->win, tagsatom, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&selmon->sel->tags, 1);
+ 		arrange(selmon);
+ 		if(viewontag)
+ 			view(arg);
+@@ -1787,6 +1800,7 @@ toggletag(const Arg *arg) {
+ 		}
+ 		selmon->sel->tags = newtags;
+ 		selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag];
++		XChangeProperty(dpy, selmon->sel->win, tagsatom, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&selmon->sel->tags, 1);
+ 		arrange(selmon);
+ 	}
+ }

patches/jokerboy/18-dwm-5.9-centred-floating.diff

+--- a/dwm.c	2011-10-03 14:03:15.981873738 +0300
++++ b/dwm.c	2011-10-03 14:07:14.185888657 +0300
+@@ -1185,8 +1185,14 @@ manage(Window w, XWindowAttributes *wa)
+ 		}
+ 	}
+ 	/* geometry */
+-	c->x = c->oldx = wa->x;
+-	c->y = c->oldy = wa->y;
++	if(!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) {
++		c->x = c->oldx = (c->mon->mw - wa->width) / 2;
++		c->y = c->oldy = (c->mon->mh - wa->height) / 2;
++	}
++	else {
++		c->x = c->oldx = wa->x;
++		c->y = c->oldy = wa->y;
++	}
+ 	c->w = c->oldw = wa->width;
+ 	c->h = c->oldh = wa->height;
+ 	c->oldbw = wa->border_width;

patches/jokerboy/PKGBUILD

+dwm_patch=${dwm_patch:-1}
+
+pkgname=dwm
+pkgver=5.9
+pkgrel=2
+pkgdesc='A dynamic window manager for X'
+url='http://dwm.suckless.org'
+arch=('i686' 'x86_64')
+license=('MIT')
+options=('zipman')
+depends=('libx11' 'libxinerama' 'dmenu')
+source=("http://dl.suckless.org/${pkgname}/${pkgname}-${pkgver}.tar.gz"
+        "01-${pkgname}-${pkgver}-pertag2.diff"
+        "02-${pkgname}-${pkgver}-push.diff"
+        "03-${pkgname}-${pkgver}-cycle.diff"
+        "04-${pkgname}-${pkgver}-gaplessgrid.diff"
+        "05-${pkgname}-${pkgver}-gaps.diff"
+        "06-${pkgname}-${pkgver}-pidgin.diff"
+        "07-${pkgname}-${pkgver}-monocle_count.diff"
+        "08-${pkgname}-${pkgver}-monocle_no_borders.diff"
+        "09-${pkgname}-${pkgver}-focusonclick.diff"
+        "10-${pkgname}-${pkgver}-viewontag.diff"
+        "11-${pkgname}-${pkgver}-urgentcolors.diff"
+        "12-${pkgname}-${pkgver}-scratchpad.diff"
+        "13-${pkgname}-${pkgver}-togglemax.diff"
+        "14-${pkgname}-${pkgver}-autoresize.diff"
+        "15-${pkgname}-${pkgver}-fix_netactivewindow.diff"
+        "16-${pkgname}-${pkgver}-increase_mfact_limit.diff"
+        "17-${pkgname}-${pkgver}-remember-tags.diff"
+        "18-${pkgname}-${pkgver}-centred-floating.diff"
+        'config.h')
+sha256sums=('2dcdd5a2a233c385ef776017263164a288886561b6bf4d6b984562f5f02fe232'
+            'c8e10624ce6199d4ec5238c483ac22a887755d7206deebc4935fb1d08ea9e9b8'
+            'ca7ece3c5f115473f872eebc825004983668e2c437b9ee2fb88804120460eb16'
+            'f5eadf88a77af9a80208c71d6b4da9ccc7988ad45f17e11b6a40da4f8707b4b2'
+            'ead4a37a656084e8d7f49967a376c89a5ec61d0fef9e72b9c45d6cbdea4bd827'
+            'b1e97733e8a3d59876ac94f6820f5ae61883c641a749dd79b4cdef99eb4d5cb7'
+            '1b9341e7f1e560213ad6c1cc013e68ab5bf8d28eaedc5e9022114222c8fb84ca'
+            '05a22c1937af4935ee803c6fb1b9a3f262208d58d8e054ab40b02cc59eb5dbe1'
+            'e40968ca9045d5e92728069189d987b5f4c75325c7427f1e246af9a95a13bb58'
+            '89a644ff5f4a70616e2cd1c4e3a914c9807bcc59ef87597e7b5b54c95568d5b3'
+            'fe5e068a9ca0edafc7040cdd2e49b69bd4f30a8c073a31a178aad3912205b621'
+            'd0976d9f1dd319f0153c4685facbd1c1f7af5e3346d2ce0fb00f5a5944b10939'
+            'b0075a03df72e66c07d3388ea5a8ab1e87ea573cf4f89dcbffb91037587a0d96'
+            'e0dbb397aef932db340c70c511ba6e87ed25a7fde331926a00a0681fa2428647'
+            'a866fbec735764382ed941a6225d8eb20154e055263ddbea731441a307637854'
+            '51bebe96d0a6027fbe94c66c0f7a23dd3ab7401a76abdb450033d01a159faaa7'
+            'e1a12fd9266d493fed28cdebaa99a0489b44ffeaa3338c1b735b01d998e8ce2d'
+            'a77fcf6f0cc84bbbf2052999a58afbbc0d197f01eb94266005ba6811259cf274'
+            '70cdda11e6bc985dfce0471a28fc3481997f398714f39236f6d708906b296943'
+            '6e1719224b655e429e930d66e61222eded03a647d38c6a24b5f407de34290d86')
+
+build() {
+  cd "${srcdir}" && cd `find . -type d -name dwm-\*`
+
+  if [ "${dwm_patch}" = 1 ]; then
+      cp "${srcdir}/config.h" config.h
+      for PATCH in $(ls ${srcdir}/??-${pkgname}-${pkgver}-*.diff); do
+          msg "$(basename ${PATCH})" && patch -Np1 -i "${PATCH}"
+    done
+  fi
+
+  sed -i \
+    -e 's/^CPPFLAGS =/CPPFLAGS +=/g' \
+    -e 's/^CFLAGS =/CFLAGS +=/g' \
+    -e 's/^LDFLAGS =/LDFLAGS +=/g' \
+    config.mk
+
+  make X11INC=/usr/include/X11 X11LIB=/usr/lib/X11
+}
+
+package() {
+  cd "${srcdir}" && cd `find . -type d -name dwm-\*`
+  make PREFIX=/usr DESTDIR="${pkgdir}" install
+  install -m644 -D LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
+  install -m644 -D README "${pkgdir}/usr/share/doc/${pkgname}/README"
+}

patches/jokerboy/config.h

+/* See LICENSE file for copyright and license details. */
+
+/* appearance */
+static const char font[]            = "-misc-fixed-medium-r-semicondensed--12-110-75-75-c-*-iso8859-2";
+static const char normbordercolor[] = "#222222";
+static const char normbgcolor[]     = "#1A1918";
+static const char normfgcolor[]     = "#807B76";
+static const char selbordercolor[]  = "#876CBE";
+static const char selbgcolor[]      = "#1A1918";
+static const char selfgcolor[]      = "#E0E0E0";
+static const char urgbordercolor[]  = "#FF1875";
+static const char urgbgcolor[]      = "#FFFFFF";
+static const char urgfgcolor[]      = "#FF1875";
+static const unsigned int borderpx  = 1;        /* border pixel of windows */
+static const unsigned int gappx     = 2;        /* gap pixel between windows */
+static const unsigned int snap      = 4;        /* snap pixel */
+static const Bool showbar           = True;     /* False means no bar */
+static const Bool topbar            = True;     /* False means bottom bar */
+static const Bool focusonclick      = True;     /* Change focus only on click */
+static const Bool viewontag         = True;     /* Switch view on tag switch */
+
+static const Rule rules[] = {
+	/* class          instance     title       tags mask     isfloating   monitor */
+	{ "MPlayer",      NULL,        NULL,       0,            True,        -1 },
+	{ "Vlc",          NULL,        NULL,       0,            True,        -1 },
+	{ "XFontSel",     NULL,        NULL,       0,            True,        -1 },
+	{ "Kcalc",        NULL,        NULL,       0,            True,        -1 },
+	{ "Chromium",     NULL,        NULL,       1 << 2,       False,       -1 },
+	{ "Firefox",      NULL,        NULL,       1 << 2,       True,        -1 },
+	{ "Firefox",      "Navigator", NULL,       1 << 2,       False,       -1 },
+	{ "Pidgin",       NULL,        NULL,       1 << 3,       False,       -1 },
+	{ "Pidgin",       NULL,        "Pidgin",   1 << 3,       True,        -1 },
+	{ "Gyachi",       NULL,        NULL,       1 << 3,       False,       -1 },
+	{ "Ktorrent",     NULL,        NULL,       1 << 4,       False,       -1 },
+	{ "VirtualBox",   NULL,        NULL,       1 << 5,       False,       -1 },
+	{ "VBoxSDL",      NULL,        NULL,       1 << 5,       False,       -1 },
+};
+
+/* layout(s) */
+static const int nmaster      = 1;     /* clients in the master area */
+static const float mfact      = 0.5;   /* factor of master area size [0.05..0.95] */
+static const Bool resizehints = False; /* True means respect size hints in tiled resizals */
+
+static const Layout layouts[] = {
+	/* symbol     gaps       arrange function */
+	{ "[T]",      True,      tile },        /* first entry is default */
+	{ "[F]",      False,     NULL },        /* no layout function means floating behavior */
+	{ "[M]",      False,     monocle },
+	{ "[N]",      True,      ntile },
+	{ "[B]",      True,      nbstack },
+	{ "[G]",      True,      gaplessgrid },
+	{ "[P]",      True,      pidgin },
+};
+
+/* tagging */
+static const Tag tags[] = {
+	/* name       layout           mfact    nmaster */
+	{ "main",     &layouts[5],     -1,      -1 },
+	{ "term",     &layouts[5],     -1,      -1 },
+	{ "web",      &layouts[2],     -1,      -1 },
+	{ "im",       &layouts[6],     0.17,    -1 },
+	{ "dld",      &layouts[5],     -1,      -1 },
+	{ "misc",     &layouts[5],     -1,      -1 },
+};
+
+/* key definitions */
+#define ALTKEY Mod1Mask
+#define MODKEY Mod4Mask
+#define TAGKEYS(KEY,TAG) \
+	{ MODKEY,                       KEY,      view,           {.ui = 1 << TAG} }, \
+	{ MODKEY|ControlMask,           KEY,      toggleview,     {.ui = 1 << TAG} }, \
+	{ MODKEY|ShiftMask,             KEY,      tag,            {.ui = 1 << TAG} }, \
+	{ MODKEY|ControlMask|ShiftMask, KEY,      toggletag,      {.ui = 1 << TAG} },
+
+/* commands */
+static const char terminal[]       = "urxvtcd";
+static const char scratchpadname[] = "scratchy";
+static const char *dmenucmd[]      = { "dmenu_run", "-i", "-p", "Run command:", "-fn", font, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL };
+static const char *termcmd[]       = { terminal, NULL };
+static const char *tmuxcmd[]       = { terminal, "-e", "tmuxa", NULL };
+static const char *musiccmd[]      = { terminal, "-e", "ncmpcpp", NULL };
+static const char *scratchpadcmd[] = { terminal, "-name", scratchpadname, "-geometry", "150x40", NULL };
+static const char *filemancmd[]    = { "dolphin", NULL };
+static const char *browsercmd[]    = { "firefox", NULL };
+static const char *altbrowsercmd[] = { "chromium", NULL };
+static const char *imcmd[]         = { "pidgin", NULL };
+static const char *vboxcmd[]       = { "VirtualBox", NULL };
+static const char *volmcmd[]       = { "amixer", "-q", "sset", "Master", "toggle", NULL };
+static const char *voldcmd[]       = { "amixer", "-q", "sset", "Master", "1-", "unmute", NULL };
+static const char *volucmd[]       = { "amixer", "-q", "sset", "Master", "1+", "unmute", NULL };
+static const char *mpdvoldcmd[]    = { "ncmpcpp", "volume", "-2", NULL };
+static const char *mpdvolucmd[]    = { "ncmpcpp", "volume", "+2", NULL };
+static const char *mpdtogglecmd[]  = { "ncmpcpp", "toggle", NULL };
+static const char *mpdstopcmd[]    = { "ncmpcpp", "stop", NULL };
+static const char *mpdprevcmd[]    = { "ncmpcpp", "prev", NULL };
+static const char *mpdnextcmd[]    = { "ncmpcpp", "next", NULL };
+static const char *screenshotcmd[] = { "printscreen", NULL };
+static const char *lockcmd[]       = { "slock", NULL };
+static const char *suspendcmd[]    = { "dbus-send", "--system", "--print-reply", "--dest=org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.UPower.Suspend", NULL };
+static const char *hibernatecmd[]  = { "dbus-send", "--system", "--print-reply", "--dest=org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.UPower.Hibernate", NULL };
+static const char *rebootcmd[]     = { "dbus-send", "--system", "--print-reply", "--dest=org.freedesktop.ConsoleKit", "/org/freedesktop/ConsoleKit/Manager", "org.freedesktop.ConsoleKit.Manager.Restart", NULL };
+static const char *shutdowncmd[]   = { "dbus-send", "--system", "--print-reply", "--dest=org.freedesktop.ConsoleKit", "/org/freedesktop/ConsoleKit/Manager", "org.freedesktop.ConsoleKit.Manager.Stop", NULL };
+
+static Key keys[] = {
+	/* modifier                     key         function        argument */
+	{ ALTKEY,                       XK_F2,      spawn,          {.v = dmenucmd} },
+	{ MODKEY|ShiftMask,             XK_Return,  spawn,          {.v = termcmd} },
+	{ MODKEY,                       XK_Return,  spawn,          {.v = tmuxcmd} },
+	{ MODKEY,                       XK_n,       spawn,          {.v = musiccmd} },
+	{ MODKEY,                       XK_x,       togglescratch,  {.v = scratchpadcmd} },
+	{ MODKEY,                       XK_t,       spawn,          {.v = filemancmd} },
+	{ MODKEY,                       XK_f,       spawn,          {.v = browsercmd} },
+	{ MODKEY,                       XK_c,       spawn,          {.v = altbrowsercmd} },
+	{ MODKEY,                       XK_p,       spawn,          {.v = imcmd} },
+	{ MODKEY,                       XK_v,       spawn,          {.v = vboxcmd} },
+	{ 0,                            0x1008ff12, spawn,          {.v = volmcmd} },
+	{ 0,                            0x1008ff11, spawn,          {.v = voldcmd} },
+	{ 0,                            0x1008ff13, spawn,          {.v = volucmd} },
+	{ MODKEY,                       0x1008ff11, spawn,          {.v = mpdvoldcmd} },
+	{ MODKEY,                       0x1008ff13, spawn,          {.v = mpdvolucmd} },
+	{ 0,                            0x1008ff14, spawn,          {.v = mpdtogglecmd} },
+	{ 0,                            0x1008ff15, spawn,          {.v = mpdstopcmd} },
+	{ 0,                            0x1008ff16, spawn,          {.v = mpdprevcmd} },
+	{ 0,                            0x1008ff17, spawn,          {.v = mpdnextcmd} },
+	{ 0,                            XK_Print,   spawn,          {.v = screenshotcmd} },
+	{ MODKEY,                       XK_j,       focusstack,     {.i = +1} },
+	{ MODKEY,                       XK_k,       focusstack,     {.i = -1} },
+	{ MODKEY,                       XK_a,       incnmaster,     {.i = +1} },
+	{ MODKEY,                       XK_z,       incnmaster,     {.i = -1} },
+	{ MODKEY,                       XK_h,       setmfact,       {.f = -0.01} },
+	{ MODKEY,                       XK_l,       setmfact,       {.f = +0.01} },
+	{ MODKEY|ShiftMask,             XK_j,       pushdown,       {0} },
+	{ MODKEY|ShiftMask,             XK_k,       pushup,         {0} },
+	{ ALTKEY,                       XK_Return,  zoom,           {0} },
+	{ MODKEY,                       XK_Tab,     view,           {0} },
+	{ MODKEY,                       XK_Escape,  killclient,     {0} },
+	{ MODKEY|ShiftMask,             XK_m,       togglemax,      {0} },
+	{ MODKEY|ShiftMask,             XK_b,       togglebar,      {0} },
+	{ MODKEY|ControlMask,           XK_t,       setlayout,      {.v = &layouts[0]} },
+	{ MODKEY|ControlMask,           XK_f,       setlayout,      {.v = &layouts[1]} },
+	{ MODKEY|ControlMask,           XK_m,       setlayout,      {.v = &layouts[2]} },
+	{ MODKEY|ControlMask,           XK_n,       setlayout,      {.v = &layouts[3]} },
+	{ MODKEY|ControlMask,           XK_b,       setlayout,      {.v = &layouts[4]} },
+	{ MODKEY|ControlMask,           XK_g,       setlayout,      {.v = &layouts[5]} },
+	{ MODKEY|ControlMask,           XK_p,       setlayout,      {.v = &layouts[6]} },
+	{ MODKEY,                       XK_space,   setlayout,      {0} },
+	{ MODKEY|ShiftMask,             XK_space,   togglefloating, {0} },
+	{ MODKEY,                       XK_0,       view,           {.ui = ~0} },
+	{ MODKEY|ShiftMask,             XK_0,       tag,            {.ui = ~0} },
+	{ MODKEY,                       XK_comma,   focusmon,       {.i = -1} },
+	{ MODKEY,                       XK_period,  focusmon,       {.i = +1} },
+	{ MODKEY|ShiftMask,             XK_comma,   tagmon,         {.i = -1} },
+	{ MODKEY|ShiftMask,             XK_period,  tagmon,         {.i = +1} },
+	{ MODKEY,                       XK_Left,    cycle,          {.i = -1} },
+	{ MODKEY,                       XK_Right,   cycle,          {.i = +1} },
+	{ MODKEY|ControlMask,           XK_Left,    tagcycle,       {.i = -1} },
+	{ MODKEY|ControlMask,           XK_Right,   tagcycle,       {.i = +1} },
+	TAGKEYS(                        XK_1,                       0)
+	TAGKEYS(                        XK_2,                       1)
+	TAGKEYS(                        XK_3,                       2)
+	TAGKEYS(                        XK_4,                       3)
+	TAGKEYS(                        XK_5,                       4)
+	TAGKEYS(                        XK_6,                       5)
+	{ 0,                            XK_Pause,   spawn,          {.v = lockcmd} },
+	{ ControlMask|ALTKEY,           XK_s,       spawn,          {.v = suspendcmd} },
+	{ ControlMask|ALTKEY,           XK_h,       spawn,          {.v = hibernatecmd} },
+	{ ControlMask|ALTKEY,           XK_r,       spawn,          {.v = rebootcmd} },
+	{ ControlMask|ALTKEY,           XK_q,       spawn,          {.v = shutdowncmd} },
+	{ MODKEY|ShiftMask,             XK_Escape,  quit,           {0} },
+};
+
+/* button definitions */
+/* click can be ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
+static Button buttons[] = {
+	/* click                event mask      button          function        argument */
+	{ ClkLtSymbol,          0,              Button1,        setlayout,      {0} },
+	{ ClkClientWin,         MODKEY,         Button1,        movemouse,      {0} },
+	{ ClkClientWin,         MODKEY,         Button2,        togglefloating, {0} },
+	{ ClkClientWin,         MODKEY,         Button3,        resizemouse,    {0} },
+	{ ClkWinTitle,          0,              Button4,        focusstack,     {.i = +1} },
+	{ ClkWinTitle,          0,              Button5,        focusstack,     {.i = -1} },
+	{ ClkTagBar,            0,              Button1,        view,           {0} },
+	{ ClkTagBar,            0,              Button3,        toggleview,     {0} },
+	{ ClkTagBar,            MODKEY,         Button1,        tag,            {0} },
+	{ ClkTagBar,            MODKEY,         Button3,        toggletag,      {0} },
+	{ ClkTagBar,            0,              Button4,        cycle,          {.i = -1} },
+	{ ClkTagBar,            0,              Button5,        cycle,          {.i = +1} },
+};

patches/pertag2-nbstack.diff

+--- a/config.def.h	2011-07-10 23:24:25.000000000 +0300
++++ b/config.def.h	2011-09-17 16:05:06.125711738 +0300
+@@ -13,9 +13,6 @@ static const unsigned int snap      = 32
+ static const Bool showbar           = True;     /* False means no bar */
+ static const Bool topbar            = True;     /* False means bottom bar */
+ 
+-/* tagging */
+-static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
+-
+ static const Rule rules[] = {
+ 	/* class      instance    title       tags mask     isfloating   monitor */
+ 	{ "Gimp",     NULL,       NULL,       0,            True,        -1 },
+@@ -23,6 +20,7 @@ static const Rule rules[] = {
+ };
+ 
+ /* layout(s) */
++static const int nmaster      = 1;    /* clients in the master area */
+ static const float mfact      = 0.55; /* factor of master area size [0.05..0.95] */
+ static const Bool resizehints = True; /* True means respect size hints in tiled resizals */
+ 
+@@ -31,6 +29,22 @@ static const Layout layouts[] = {
+ 	{ "[]=",      tile },    /* first entry is default */
+ 	{ "><>",      NULL },    /* no layout function means floating behavior */
+ 	{ "[M]",      monocle },
++	{ "[N]",      ntile },
++	{ "[S]",      nbstack },
++};
++
++/* tagging */
++	static const Tag tags[] = {
++	/* name       layout           mfact    nmaster */
++	{ "1",        &layouts[0],     -1,      -1 },
++	{ "2",        &layouts[1],     -1,      -1 },
++	{ "3",        &layouts[2],     -1,      -1 },
++	{ "4",        &layouts[3],     0.40,    -1 },
++	{ "5",        &layouts[0],     -1,      -1 },
++	{ "6",        &layouts[0],     -1,      -1 },
++	{ "7",        &layouts[0],     -1,      -1 },
++	{ "8",        &layouts[0],     -1,      -1 },
++	{ "9",        &layouts[0],     -1,      -1 },
+ };
+ 
+ /* key definitions */
+@@ -55,6 +69,8 @@ static Key keys[] = {
+ 	{ MODKEY,                       XK_b,      togglebar,      {0} },
+ 	{ MODKEY,                       XK_j,      focusstack,     {.i = +1 } },
+ 	{ MODKEY,                       XK_k,      focusstack,     {.i = -1 } },
++	{ MODKEY,                       XK_a,      incnmaster,     {.i = +1 } },
++	{ MODKEY,                       XK_z,      incnmaster,     {.i = -1 } },
+ 	{ MODKEY,                       XK_h,      setmfact,       {.f = -0.05} },
+ 	{ MODKEY,                       XK_l,      setmfact,       {.f = +0.05} },
+ 	{ MODKEY,                       XK_Return, zoom,           {0} },
+@@ -63,6 +79,8 @@ static Key keys[] = {
+ 	{ MODKEY,                       XK_t,      setlayout,      {.v = &layouts[0]} },
+ 	{ MODKEY,                       XK_f,      setlayout,      {.v = &layouts[1]} },
+ 	{ MODKEY,                       XK_m,      setlayout,      {.v = &layouts[2]} },
++	{ MODKEY,                       XK_n,      setlayout,      {.v = &layouts[3]} },
++	{ MODKEY,                       XK_s,      setlayout,      {.v = &layouts[4]} },
+ 	{ MODKEY,                       XK_space,  setlayout,      {0} },
+ 	{ MODKEY|ShiftMask,             XK_space,  togglefloating, {0} },
+ 	{ MODKEY,                       XK_0,      view,           {.ui = ~0 } },
+--- a/dwm.c	2011-07-10 23:24:25.000000000 +0300
++++ b/dwm.c	2011-09-17 16:03:56.589707375 +0300
+@@ -124,7 +124,6 @@ typedef struct {
+ 
+ struct Monitor {
+ 	char ltsymbol[16];
+-	float mfact;
+ 	int num;
+ 	int by;               /* bar geometry */
+ 	int mx, my, mw, mh;   /* screen size */
+@@ -140,9 +139,21 @@ struct Monitor {
+ 	Monitor *next;
+ 	Window barwin;
+ 	const Layout *lt[2];
++	int curtag;
++	int prevtag;
++	const Layout **lts;
++	double *mfacts;
++	int *nmasters;
+ };
+ 
+ typedef struct {
++	const char *name;
++	const Layout *layout;
++	float mfact;
++	int nmaster;
++} Tag;
++
++typedef struct {
+ 	const char *class;
+ 	const char *instance;
+ 	const char *title;
+@@ -244,6 +255,9 @@ static int xerror(Display *dpy, XErrorEv
+ static int xerrordummy(Display *dpy, XErrorEvent *ee);
+ static int xerrorstart(Display *dpy, XErrorEvent *ee);
+ static void zoom(const Arg *arg);
++static void incnmaster(const Arg *arg);
++static void ntile(Monitor *m);
++static void nbstack(Monitor *m);
+ 
+ /* variables */
+ static const char broken[] = "broken";
+@@ -434,7 +448,7 @@ buttonpress(XEvent *e) {
+ 	if(ev->window == selmon->barwin) {
+ 		i = x = 0;
+ 		do {
+-			x += TEXTW(tags[i]);
++			x += TEXTW(tags[i].name);
+ 		} while(ev->x >= x && ++i < LENGTH(tags));
+ 		if(i < LENGTH(tags)) {
+ 			click = ClkTagBar;
+@@ -506,6 +520,9 @@ cleanupmon(Monitor *mon) {
+ 	}
+ 	XUnmapWindow(dpy, mon->barwin);
+ 	XDestroyWindow(dpy, mon->barwin);
++	free(mon->mfacts);
++	free(mon->nmasters);
++	free(mon->lts);
+ 	free(mon);
+ }
+ 
+@@ -651,16 +668,31 @@ configurerequest(XEvent *e) {
+ Monitor *
+ createmon(void) {
+ 	Monitor *m;
++	int i, numtags = LENGTH(tags) + 1;
+ 
+ 	if(!(m = (Monitor *)calloc(1, sizeof(Monitor))))
+ 		die("fatal: could not malloc() %u bytes\n", sizeof(Monitor));
++	if(!(m->mfacts = calloc(sizeof(double), numtags)))
++		die("fatal: could not malloc() %u bytes\n", sizeof(double) * numtags);
++	if(!(m->nmasters = calloc(sizeof(int), numtags)))
++		die("fatal: could not malloc() %u bytes\n", sizeof(int) * numtags);
++	if(!(m->lts = calloc(sizeof(Layout *), numtags)))
++		die("fatal: could not malloc() %u bytes\n", sizeof(Layout *) * numtags);
+ 	m->tagset[0] = m->tagset[1] = 1;
+-	m->mfact = mfact;
++	m->mfacts[0] = mfact;
++	m->nmasters[0] = nmaster;
++	m->lts[0] = &layouts[0];
+ 	m->showbar = showbar;
+ 	m->topbar = topbar;
+-	m->lt[0] = &layouts[0];
++	m->curtag = m->prevtag = 1;
++	for(i = 1; i < numtags; i++) {
++		m->mfacts[i] = tags[i - 1].mfact < 0 ? mfact : tags[i - 1].mfact;
++		m->nmasters[i] = tags[i - 1].nmaster < 0 ? nmaster : tags[i - 1].nmaster;
++		m->lts[i] = tags[i - 1].layout;
++	}
++	m->lt[0] = m->lts[m->curtag];
+ 	m->lt[1] = &layouts[1 % LENGTH(layouts)];
+-	strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
++	strncpy(m->ltsymbol, m->lt[0]->symbol, sizeof m->ltsymbol);
+ 	return m;
+ }
+ 
+@@ -735,9 +767,9 @@ drawbar(Monitor *m) {
+ 	}
+ 	dc.x = 0;
+ 	for(i = 0; i < LENGTH(tags); i++) {
+-		dc.w = TEXTW(tags[i]);
++		dc.w = TEXTW(tags[i].name);
+ 		col = m->tagset[m->seltags] & 1 << i ? dc.sel : dc.norm;
+-		drawtext(tags[i], col, urg & 1 << i);
++		drawtext(tags[i].name, col, urg & 1 << i);
+ 		drawsquare(m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
+ 		           occ & 1 << i, urg & 1 << i, col);
+ 		dc.x += dc.w;
+@@ -1498,7 +1530,7 @@ setlayout(const Arg *arg) {
+ 	if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])