dwm-gridmode-5.8.2.diff - sites - public wiki contents of suckless.org | |
git clone git://git.suckless.org/sites | |
Log | |
Files | |
Refs | |
--- | |
dwm-gridmode-5.8.2.diff (1246B) | |
--- | |
1 diff -r 62791cc97f88 config.def.h | |
2 --- a/config.def.h Tue Jun 01 17:39:26 2010 +0100 | |
3 +++ b/config.def.h Wed Jun 02 13:42:49 2010 +0100 | |
4 @@ -29,1 +29,2 @@ | |
5 +#include "grid.c" | |
6 static const Layout layouts[] = { | |
7 @@ -34,3 +35,4 @@ | |
8 + { "HHH", grid }, | |
9 }; | |
10 | |
11 /* key definitions */ | |
12 diff -r 62791cc97f88 grid.c | |
13 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | |
14 +++ b/grid.c Wed Jun 02 13:42:49 2010 +0100 | |
15 @@ -0,0 +1,28 @@ | |
16 +void | |
17 +grid(Monitor *m) { | |
18 + unsigned int i, n, cx, cy, cw, ch, aw, ah, cols, rows; | |
19 + Client *c; | |
20 + | |
21 + for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next)) | |
22 + n++; | |
23 + | |
24 + /* grid dimensions */ | |
25 + for(rows = 0; rows <= n/2; rows++) | |
26 + if(rows*rows >= n) | |
27 + break; | |
28 + cols = (rows && (rows - 1) * rows >= n) ? rows - 1 : rows; | |
29 + | |
30 + /* window geoms (cell height/width) */ | |
31 + ch = m->wh / (rows ? rows : 1); | |
32 + cw = m->ww / (cols ? cols : 1); | |
33 + for(i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next)… | |
34 + cx = m->wx + (i / rows) * cw; | |
35 + cy = m->wy + (i % rows) * ch; | |
36 + /* adjust height/width of last row/column's windows */ | |
37 + ah = ((i + 1) % rows == 0) ? m->wh - ch * rows : 0; | |
38 + aw = (i >= rows * (cols - 1)) ? m->ww - cw * cols : 0; | |
39 + resize(c, cx, cy, cw - 2 * c->bw + aw, ch - 2 * c->bw +… | |
40 + i++; | |
41 + } | |
42 +} | |
43 + |