diff -Naur --exclude='.hg*' dwm-tip/config.default.h dwm-grid/config.default.h --- dwm-tip/config.default.h 2007-02-25 23:26:01.000000000 +0200 +++ dwm-grid/config.default.h 2007-02-26 07:56:10.000000000 +0200 @@ -32,6 +32,7 @@ /* symbol function */ \ { "[]=", tile }, /* first entry is default */ \ { "><>", floating }, \ + { "+++", grid }, \ }; #define MASTERWIDTH 600 /* master width per thousand */ #define NMASTER 1 /* clients in master area */ diff -Naur --exclude='.hg*' dwm-tip/layout.c dwm-grid/layout.c --- dwm-tip/layout.c 2007-02-25 23:26:02.000000000 +0200 +++ dwm-grid/layout.c 2007-02-26 07:58:57.000000000 +0200 @@ -14,6 +14,49 @@ static unsigned int nmaster = NMASTER; static void +grid(void) { + unsigned int i, n, nx, ny, nw, nh, tw, th, cols, rows; + Client *c; + + for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) + n++; + + for(rows = 0; rows <= n/2; rows++) + if(rows*rows >= n) + break; + cols = (rows && (rows - 1) * rows >= n) ? rows - 1 : rows; + + th = (sh - dc.h) / (rows ? rows : 1); + tw = sw / (cols ? cols : 1); + nw = tw - 2 * BORDERPX; + nh = th - 2 * BORDERPX; + + for(i = 0, c = clients; c; c = c->next) + if(isvisible(c)) { + if(c->isbanned) + XMoveWindow(dpy, c->win, c->x, c->y); + c->isbanned = False; + if(c->isfloating) + continue; + c->ismax = False; + nx = (i / rows) * tw; + ny = (i % rows) * th + (TOPBAR ? dc.h : 0); + resize(c, nx, ny, nw, nh, False); + i++; + } + else { + c->isbanned = True; + XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); + } + + if(!sel || !isvisible(sel)) { + for(c = stack; c && !isvisible(c); c = c->snext); + focus(c); + } + restack(); +} + +static void tile(void) { unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th; Client *c;