diff -Naur --exclude='.hg*' dwm-tip/config.default.h dwm-tip-custom/config.default.h --- dwm-tip/config.default.h 2007-01-31 00:12:46.000000000 +0200 +++ dwm-tip-custom/config.default.h 2007-02-02 13:32:26.000000000 +0200 @@ -9,6 +9,7 @@ #define DEFMODE dotile /* dofloat */ #define FLOATSYMBOL "><>" #define TILESYMBOL "[]=" +#define GRIDSYMBOL "[-]" #define FONT "-*-fixed-medium-r-normal-*-13-*-*-*-*-*-*-*" #define NORMBORDERCOLOR "#dddddd" diff -Naur --exclude='.hg*' dwm-tip/draw.c dwm-tip-custom/draw.c --- dwm-tip/draw.c 2007-01-31 00:12:46.000000000 +0200 +++ dwm-tip-custom/draw.c 2007-02-02 13:21:00.000000000 +0200 @@ -111,7 +111,7 @@ dc.x += dc.w; } dc.w = bmw; - drawtext(arrange == dofloat ? FLOATSYMBOL : TILESYMBOL, dc.norm, False, False); + drawtext(arrange == dofloat ? FLOATSYMBOL : (arrange == dogrid ? GRIDSYMBOL : TILESYMBOL), dc.norm, False, False); x = dc.x + dc.w; dc.w = textw(stext); dc.x = sw - dc.w; diff -Naur --exclude='.hg*' dwm-tip/dwm.h dwm-tip-custom/dwm.h --- dwm-tip/dwm.h 2007-02-02 12:47:36.000000000 +0200 +++ dwm-tip-custom/dwm.h 2007-02-02 13:30:19.000000000 +0200 @@ -139,11 +139,13 @@ extern void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */ extern void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */ extern void spawn(Arg *arg); /* forks a new subprocess with to arg's cmd */ +extern unsigned int grid_cols(unsigned int n); /* determine the number of columns in grid mode */ /* view.c */ extern void detach(Client *c); /* detaches c from global client list */ extern void dofloat(void); /* arranges all windows floating */ extern void dotile(void); /* arranges all windows tiled */ +extern void dogrid(void); /* arranges all windows in a grid */ extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */ extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */ extern void incnmaster(Arg *arg); /* increments nmaster with arg's index value */ diff -Naur --exclude='.hg*' dwm-tip/util.c dwm-tip-custom/util.c --- dwm-tip/util.c 2007-01-31 00:12:46.000000000 +0200 +++ dwm-tip-custom/util.c 2007-02-02 13:22:24.000000000 +0200 @@ -52,3 +52,12 @@ } wait(0); } + +unsigned int grid_cols(unsigned int n) { + unsigned int i; + for(i = 0; i <= n/2; i++) + if(i*i >= n) + break; + return i; +} + diff -Naur --exclude='.hg*' dwm-tip/view.c dwm-tip-custom/view.c --- dwm-tip/view.c 2007-02-02 12:49:14.000000000 +0200 +++ dwm-tip-custom/view.c 2007-02-02 13:25:14.000000000 +0200 @@ -118,6 +118,48 @@ } void +dogrid(void) { + unsigned int i, n, tw, th, cols, rows; + Client *c; + + for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) + n++; + + if (n == 0) + return; + + cols = grid_cols(n); + rows = cols; + if (((cols - 1) * rows) >= n) + cols--; + + th = (sh - dc.h) / rows; + tw = sw / cols; + + for(i = 0, c = clients; c; c = c->next) + if(isvisible(c)) { + if(c->isfloat) { + resize(c, True); + continue; + } + c->ismax = False; + c->x = (i / rows) * tw; + c->y = (i % rows) * th + dc.h; + c->w = tw - 2 * BORDERPX; + c->h = th - 2 * BORDERPX; + resize(c, False); + i++; + } + else + 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(); +} + +void focusnext(Arg *arg) { Client *c; @@ -215,7 +257,8 @@ void togglemode(Arg *arg) { - arrange = (arrange == dofloat) ? dotile : dofloat; + arrange = (arrange == dofloat) ? + dotile : (arrange == dotile) ? dogrid : dofloat; if(sel) arrange(); else