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