diff -r 795c26a59016 config.default.h --- a/config.default.h Sun Aug 26 12:54:20 2007 +0200 +++ b/config.default.h Sat Sep 01 20:06:19 2007 +0200 @@ -26,11 +26,13 @@ static Rule rules[] = { \ /* layout(s) */ #include "tile.h" +#include "grid.h" #define LAYOUTS \ static Layout layouts[] = { \ /* symbol function */ \ { "[]=", tile }, /* first entry is default */ \ { "><>", floating }, \ + { "+++", grid }, \ }; #define MWFACT 0.6 /* master width factor [0.1 .. 0.9] */ #define SNAP 32 /* snap pixel */ diff -r 795c26a59016 config.mk --- a/config.mk Sun Aug 26 12:54:20 2007 +0200 +++ b/config.mk Sat Sep 01 20:06:19 2007 +0200 @@ -4,7 +4,7 @@ VERSION = 4.4.1 # Customize below to fit your system # additional layouts beside floating -SRC = tile.c +SRC = tile.c grid.c # paths PREFIX = /usr/local diff -r 795c26a59016 grid.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/grid.c Sat Sep 01 20:06:19 2007 +0200 @@ -0,0 +1,32 @@ +/* See LICENSE file for copyright and license details. */ +#include "dwm.h" + +/* extern */ +void +grid(void) { + unsigned int i, n, cx, cy, cw, ch, aw, ah, cols, rows; + Client *c; + + for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) + n++; + + /* grid dimensions */ + for(rows = 0; rows <= n/2; rows++) + if(rows*rows >= n) + break; + cols = (rows && (rows - 1) * rows >= n) ? rows - 1 : rows; + + /* window geoms (cell height/width) */ + ch = wah / (rows ? rows : 1); + cw = waw / (cols ? cols : 1); + + for(i = 0, c = nexttiled(clients); c; c = nexttiled(c->next), i++) { + c->ismax = False; + cx = (i / rows) * cw; + cy = (i % rows) * ch + (bpos == BarTop ? bh : 0); /* bh? adjust */ + /* adjust height/width of last row/column's windows */ + ah = ((i + 1) % rows == 0) ? wah - ch * rows : 0; + aw = (i >= rows * (cols - 1)) ? waw - cw * cols : 0; + resize(c, cx, cy, cw - 2 * c->border + aw, ch - 2 * c->border + ah, False); + } +} diff -r 795c26a59016 grid.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/grid.h Sat Sep 01 20:06:19 2007 +0200 @@ -0,0 +1,4 @@ +/* See LICENSE file for copyright and license details. */ + +/* grid.c */ +void grid(void); /* arranges all windows on a grid */