diff -Naur --exclude='.hg*' dwm-tip/config.default.h dwm-grid/config.default.h --- dwm-tip/config.default.h 2007-02-21 16:43:04.000000000 +0200 +++ dwm-grid/config.default.h 2007-02-21 16:45:49.000000000 +0200 @@ -33,6 +33,7 @@ /* symbol function */ \ { "[]=", tile }, /* first entry is default */ \ { "><>", versatile }, \ + { "+++", grid }, \ }; #define MASTER 600 /* per thousand */ #define NMASTER 1 /* clients in master area */ diff -Naur --exclude='.hg*' dwm-tip/dwm.h dwm-grid/dwm.h --- dwm-tip/dwm.h 2007-02-21 16:43:04.000000000 +0200 +++ dwm-grid/dwm.h 2007-02-21 16:46:32.000000000 +0200 @@ -153,4 +153,6 @@ 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 arg's cmd */ +/* grid mode */ +extern void grid(void); /* grid mode layout */ diff -Naur --exclude='.hg*' dwm-tip/layout_grid.c dwm-grid/layout_grid.c --- dwm-tip/layout_grid.c 1970-01-01 02:00:00.000000000 +0200 +++ dwm-grid/layout_grid.c 2007-02-21 16:46:48.000000000 +0200 @@ -0,0 +1,47 @@ +#include "dwm.h" + +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(); +} + diff -Naur --exclude='.hg*' dwm-tip/Makefile dwm-grid/Makefile --- dwm-tip/Makefile 2007-02-21 16:43:04.000000000 +0200 +++ dwm-grid/Makefile 2007-02-21 16:44:33.000000000 +0200 @@ -3,7 +3,7 @@ include config.mk -SRC = client.c draw.c event.c layout.c main.c tag.c util.c +SRC = client.c draw.c event.c layout.c main.c tag.c util.c layout_grid.c OBJ = ${SRC:.c=.o} all: options dwm