diff -r 5f8b05768780 config.arg.h --- a/config.arg.h Wed Feb 21 15:47:52 2007 +0100 +++ b/config.arg.h Wed Feb 21 16:08:05 2007 +0100 @@ -32,6 +32,7 @@ static Layout layout[] = { \ /* symbol function */ \ { "[]=", tile }, /* first entry is default */ \ { "><>", versatile }, \ + { "+++", grid }, \ }; #define MASTER 600 /* per thousand */ #define NMASTER 1 /* clients in master area */ diff -r 5f8b05768780 config.default.h --- a/config.default.h Wed Feb 21 15:47:52 2007 +0100 +++ b/config.default.h Wed Feb 21 16:09:35 2007 +0100 @@ -33,6 +33,7 @@ static Layout layout[] = { \ /* symbol function */ \ { "[]=", tile }, /* first entry is default */ \ { "><>", versatile }, \ + { "+++", grid }, \ }; #define MASTER 600 /* per thousand */ #define NMASTER 1 /* clients in master area */ diff -r 5f8b05768780 layout.c --- a/layout.c Wed Feb 21 15:47:52 2007 +0100 +++ b/layout.c Wed Feb 21 16:09:16 2007 +0100 @@ -11,6 +11,48 @@ Layout *lt = NULL; /* static */ static unsigned int nlayouts = 0; + +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; + if (n > 0) { + th = (sh - dc.h) / rows; + tw = sw / cols; + } + 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->isversatile) + continue; + c->ismax = False; + nx = (i / rows) * tw; + ny = (i % rows) * th + (TOPBAR ? dc.h : 0); + nw = tw - 2 * BORDERPX; + nh = th - 2 * BORDERPX; + 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) {