dwm-r1437-gaplessgrid.diff (1890B)
1 diff -up dwm-5.2-original/config.def.h dwm-5.2-modified/config.def.h 2 --- dwm-5.2-original/config.def.h 2008-09-09 21:46:17.000000000 +0200 3 +++ dwm-5.2-modified/config.def.h 2008-10-20 20:07:42.000000000 +0200 4 @@ -28,11 +28,13 @@ static Rule rules[] = { 5 static float mfact = 0.55; /* factor of master area size [0.05..0.95] */ 6 static Bool resizehints = True; /* False means respect size hints in tiled resizals */ 7 8 +#include "gaplessgrid.c" 9 static Layout layouts[] = { 10 /* symbol arrange function */ 11 { "[]=", tile }, /* first entry is default */ 12 { "><>", NULL }, /* no layout function means floating behavior */ 13 { "[M]", monocle }, 14 + { "###", gaplessgrid }, 15 }; 16 17 /* key definitions */ 18 diff -up dwm-5.2-original/gaplessgrid.c dwm-5.2-modified/gaplessgrid.c 19 --- /dev/null 2008-10-20 20:09:51.000000000 +0200 20 +++ dwm-5.2-modified/gaplessgrid.c 2008-10-20 20:06:59.000000000 +0200 21 @@ -0,0 +1,38 @@ 22 +void 23 +gaplessgrid(Monitor *m) { 24 + unsigned int n, cols, rows, cn, rn, i, cx, cy, cw, ch; 25 + Client *c; 26 + 27 + for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next)) 28 + n++; 29 + if(n == 0) 30 + return; 31 + 32 + /* grid dimensions */ 33 + for(cols = 0; cols <= n/2; cols++) 34 + if(cols*cols >= n) 35 + break; 36 + if(n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */ 37 + cols = 2; 38 + rows = n/cols; 39 + 40 + /* window geometries (cell height/width/x/y) */ 41 + cw = m->ww / (cols ? cols : 1); 42 + cn = 0; /* current column number */ 43 + rn = 0; /* current row number */ 44 + for(i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next)) { 45 + if(i/rows+1 > cols-n%cols) 46 + rows = n/cols+1; 47 + ch = m->wh / (rows ? rows : 1); 48 + cx = m->wx + cn*cw; 49 + cy = m->wy + rn*ch; 50 + resize(c, cx, cy, cw - 2 * c->bw, ch - 2 * c->bw); 51 + 52 + i++; 53 + rn++; 54 + if(rn >= rows) { /* jump to the next column */ 55 + rn = 0; 56 + cn++; 57 + } 58 + } 59 +}