diff -r e9f9232bb008 -r 87f70c4d5b0d config.def.h --- a/config.def.h Sun Nov 25 17:20:48 2007 -0500 +++ b/config.def.h Sun Nov 25 17:25:56 2007 -0500 @@ -29,6 +29,7 @@ Layout layouts[] = { Layout layouts[] = { /* symbol function */ { "[]=", tile }, /* first entry is default */ + { "+++", grid }, { "><>", floating }, }; diff -r e9f9232bb008 -r 87f70c4d5b0d dwm.c --- a/dwm.c Sun Nov 25 17:20:48 2007 -0500 +++ b/dwm.c Sun Nov 25 17:25:56 2007 -0500 @@ -146,6 +146,7 @@ Bool gettextprop(Window w, Atom atom, ch Bool gettextprop(Window w, Atom atom, char *text, unsigned int size); void grabbuttons(Client *c, Bool focused); void grabkeys(void); +void grid(void); unsigned int idxoftag(const char *tag); void initfont(const char *fontstr); Bool isoccupied(unsigned int t); @@ -869,6 +870,38 @@ grabkeys(void) { } } +void +grid(void) { + unsigned int i, n, cx, cy, cw, ch, aw, ah, cols, rows, m; + Client *c; + + for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) + n++; + + /* grid dimensions */ + for(cols = 0; cols*cols < n; cols++); + rows = (cols && (cols - 1) * cols >= n) ? cols - 1 : cols; + + /* window geoms (cell height/width) */ + cw = waw / (cols ? cols : 1); + m = rows*cols - n; + for(i = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) { + c->ismax = False; + if(m > 0 && i < rows - m){ + ch = wah / (rows - m ? rows - m : 1); + cx = 0; + cy = (i % (rows - m)) * ch; + }else{ + ch = wah / (rows ? rows : 1); + cx = ((i + m) / rows) * cw; + cy = ((i + m) % rows) * ch; // bh? adjust + } + cy += (bpos == BarTop ? bh : 0); // bh? adjust + resize(c, cx, cy, cw - 2 * c->border, ch - 2 * c->border, False); + i++; + } +} + unsigned int idxoftag(const char *tag) { unsigned int i;