Below is a patch for the current release (4.4.1) of dwm which enables
multiple columns in the stacking area. It introduces variables nrows and
ncols with corresponding default values NROWS and NCOLS in
config.h.default, and corresponding setnrows() and setncols() for use in
keybindings.
If nrows == ncols == 0, tile() behaves in the normal manner. When nrows
0, tile() creates an extra column if adding another window to the current
one would cause it to exceed nrows clients. If ncols 0, the maximum
number of columns created cannot exceed ncols, overriding the nrows
setting. The patch also reintroduces nmaster in a similar way to the
existing nmaster patch, but allows it to be zero to simulate a grid mode.
Where there are not enough windows to fill all the columns evenly, the
extra space is used by the top-most client in the first column.
I'd be interested in any feedback. (I use this 'extended tiling' mode
myself, and so intend to maintain the patch going forward.)
Best wishes,
Chris.
diff -uNrd dwm-4.4.1.orig/config.default.h dwm-4.4.1/config.default.h
--- dwm-4.4.1.orig/config.default.h 2007-08-26 11:53:49.0 +0100
+++ dwm-4.4.1/config.default.h 2007-09-09 16:35:23.0 +0100
@@ -33,6 +33,9 @@
{ ,floating }, \
};
#define MWFACT 0.6 /* master width factor [0.1 .. 0.9] */
+#define NMASTER1 /* clients in master area */
+#define NROWS 2 /* clients per column in stacking area
*/
+#define NCOLS 3 /* maximum number of stacking area
columns */
#define SNAP 32 /* snap pixel */
/* key definitions */
@@ -48,6 +51,12 @@
{ MODKEY, XK_k, focusprev, NULL },
\
{ MODKEY, XK_h, setmwfact, -0.05
}, \
{ MODKEY, XK_l, setmwfact, +0.05
}, \
+ { MODKEY|ShiftMask, XK_j, setnrows, -1 },
\
+ { MODKEY|ShiftMask, XK_k, setnrows, +1 },
\
+ { MODKEY|ControlMask, XK_j, setncols, -1 },
\
+ { MODKEY|ControlMask, XK_k, setncols, +1 },
\
+ { MODKEY|ShiftMask, XK_h, setnmaster, -1 },
\
+ { MODKEY|ShiftMask, XK_l, setnmaster, +1 },
\
{ MODKEY, XK_m, togglemax, NULL },
\
{ MODKEY, XK_Return, zoom, NULL },
\
{ MODKEY|ShiftMask, XK_space, togglefloating, NULL },
\
diff -uNrd dwm-4.4.1.orig/tile.c dwm-4.4.1/tile.c
--- dwm-4.4.1.orig/tile.c 2007-08-26 11:53:49.0 +0100
+++ dwm-4.4.1/tile.c2007-09-09 16:34:17.0 +0100
@@ -5,10 +5,82 @@
/* static */
static double mwfact = MWFACT;
+static unsigned int nmaster = NMASTER;
+static unsigned int nrows = NROWS;
+static unsigned int ncols = NCOLS;
/* extern */
void
+setnmaster(const char *arg) {
+ int i;
+
+ if(!isarrange(tile))
+ return;
+ if(!arg)
+ i = NMASTER;
+ else if(arg[0] != '+' arg[0] != '-')
+ i = atoi(arg);
+ else
+ i = nmaster + atoi(arg);
+
+ if(i 0 || wah = 2 * BORDERPX * i)
+ return;
+
+ nmaster = i;
+ if(sel)
+ arrange();
+ else
+ drawstatus();
+}
+
+void
+setnrows(const char *arg) {
+ int i;
+
+ if(!isarrange(tile))
+ return;
+ if(!arg)
+ i = NROWS;
+ else if(arg[0] != '+' arg[0] != '-')
+ i = atoi(arg);
+ else
+ i = nrows + atoi(arg);
+
+ if(i 0 || wah = 2 * BORDERPX * i)
+ return;
+ nrows = i;
+
+ if(sel)
+ arrange();
+ else
+ drawstatus();
+}
+
+void
+setncols(const char *arg) {
+ int i;
+
+ if(!isarrange(tile))
+ return;
+ if(!arg)
+ i = NCOLS;
+ else if(arg[0] != '+' arg[0] != '-')
+ i = atoi(arg);
+ else
+ i = ncols + atoi(arg);
+
+ if((i 0) || (i = 1 waw / i = 2 * BORDERPX))
+ return;
+ ncols = i;
+
+ if(sel)
+ arrange();
+ else
+ drawstatus();
+}
+
+void
setmwfact(const char *arg) {
double delta;
@@ -32,40 +104,79 @@
void
tile(void) {
- unsigned int i, n, nx, ny, nw, nh, mw, th;
+ unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th, tw1, cols, rows,
rows1;
Client *c;
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c-next))
n++;
+ /* calculate correct number of rows */
+ if(ncols 0 n - nmaster nrows * ncols)
+ rows = (n - nmaster) / ncols + ((n - nmaster) % ncols ? 1 :