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-03-05 17:16:29.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-26 14:36:31.000000000 +0200 +++ dwm-grid/layout.c 2007-03-05 17:22:24.000000000 +0200 @@ -14,6 +14,52 @@ static unsigned int nmaster = NMASTER; static void +grid(void) { + unsigned int i, n, nx, ny, nw, nh, aw, ah, 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); + /* adjust height and width of last row's and last column's windows */ + ah = ((i + 1) % rows == 0) ? sh - th * rows - dc.h : 0; + aw = (i >= rows * (cols - 1)) ? sw - tw * cols : 0; + resize(c, nx, ny, nw + aw, nh + ah, 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;