I've written a patch for dwm to limit the number of clients per tag
to be displayed, usually you work with 2 or 3 windows at the same time,
no more, the rest are less important, so you can switch between (all or 2)
windows per tag with a keybinding.

        { MODKEY,                       XK_w,           clientspertag,  "0" }, \
        { MODKEY|ShiftMask,             XK_w,           clientspertag,  "2" }, \

The patch is really simple and not really intrusive, the only annoying thing
is that you can walk over non-visible clients on the slave area, but this can be
a feature if you know what windows are there allowing you to switch between
N+1 windows easily.

clientspertag("0"); -> show all windows
clientspertag("2"); -> shows only two windows

arg what do you think about adding this to dwm?

another possible implementation would implementing the clientspertag() function
as a toggable option, so you will not need to press two different keys for this
and defining the clients_per_tag value as #define in config.h 

  --pancake
diff -r d9c7c686d4dc client.c
--- a/client.c	Fri Jun 01 12:11:25 2007 +0200
+++ b/client.c	Sun Jun 10 17:38:57 2007 +0200
@@ -400,3 +400,25 @@ unmanage(Client *c) {
 	XUngrabServer(dpy);
 	lt->arrange();
 }
+
+void clientspertag(const char *arg) {
+	cpt = atoi(arg);
+	lt->arrange();
+}
diff -r d9c7c686d4dc dwm.h
--- a/dwm.h	Fri Jun 01 12:11:25 2007 +0200
+++ b/dwm.h	Sun Jun 10 17:00:08 2007 +0200
@@ -82,6 +82,7 @@ extern char stext[256];				/* status tex
 extern char stext[256];				/* status text */
 extern int screen, sx, sy, sw, sh;		/* screen geometry */
 extern int wax, way, wah, waw;			/* windowarea geometry */
+extern int cpt;                                 /* clients per tag limit */
 extern unsigned int bh, blw, bpos;		/* bar height, bar layout label width, bar position */
 extern unsigned int ntags, numlockmask;		/* number of tags, numlock mask */
 extern void (*handler[LASTEvent])(XEvent *);	/* event handler */
@@ -147,3 +148,5 @@ void *emallocz(unsigned int size);	/* al
 void *emallocz(unsigned int size);	/* allocates zero-initialized memory, exits on error */
 void eprint(const char *errstr, ...);	/* prints errstr and exits with 1 */
 void spawn(const char *arg);		/* forks a new subprocess with arg's cmd */
+void clientspertag(const char *arg);    /* limit number of clients per tag */
diff -r d9c7c686d4dc layout.c
--- a/layout.c	Fri Jun 01 12:11:25 2007 +0200
+++ b/layout.c	Sun Jun 10 17:14:57 2007 +0200
@@ -34,6 +34,7 @@ tile(void) {
 
 	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
 		n++;
+	if (cpt&&n>cpt) n = cpt;
 	/* window geoms */
 	mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1);
 	mw = (n > nmaster) ? (waw * masterw) / 1000 : waw;
@@ -71,6 +72,7 @@ tile(void) {
 			}
 			resize(c, nx, ny, nw, nh, False);
 			i++;
+			if (cpt && i>cpt) break;
 		}
 		else
 			ban(c);
diff -r d9c7c686d4dc main.c
--- a/main.c	Fri Jun 01 12:11:25 2007 +0200
+++ b/main.c	Sun Jun 10 17:39:59 2007 +0200
@@ -15,7 +15,7 @@
 /* extern */
 
 char stext[256];
-int screen, sx, sy, sw, sh, wax, way, waw, wah;
+int screen, sx, sy, sw, sh, wax, way, waw, wah, cpt;
 unsigned int bh, bpos, ntags, numlockmask;
 Atom wmatom[WMLast], netatom[NetLast];
 Bool *seltag;
@@ -180,6 +180,7 @@ setup(void) {
 	initfont(FONT);
 	/* geometry */
 	sx = sy = 0;
+	cpt = 0;
 	sw = DisplayWidth(dpy, screen);
 	sh = DisplayHeight(dpy, screen);
 	initlayouts();

Reply via email to