Ev'ning once more,

I just updated the gridmode patch for dwm 5.2 and fixed
a small issue with the bar-offset.

btw: anyone knows about a bug in dwm 5.2 which causes
badly drawn borders when toggling the bar to be shown again?


v4hn
diff -NrU2 dwm-5.2/config.def.h dwm-5.2-playground/config.def.h
--- dwm-5.2/config.def.h        2008-09-09 21:46:17.000000000 +0200
+++ dwm-5.2-playground/config.def.h     2008-10-15 16:02:41.000000000 +0200
@@ -29,4 +29,5 @@
 static Bool resizehints = True; /* False means respect size hints in tiled 
resizals */
 
+#include "grid.c"
 static Layout layouts[] = {
        /* symbol     arrange function */
@@ -34,4 +35,5 @@
        { "><>",      NULL },    /* no layout function means floating behavior 
*/
        { "[M]",      monocle },
+       { "+++",      grid },
 };
 
diff -NrU2 dwm-5.2/grid.c dwm-5.2-playground/grid.c
--- dwm-5.2/grid.c      1970-01-01 01:00:00.000000000 +0100
+++ dwm-5.2-playground/grid.c   2008-10-15 16:03:05.000000000 +0200
@@ -0,0 +1,28 @@
+void
+grid() {
+       unsigned int i, n, cx, cy, cw, ch, aw, ah, cols, rows;
+       Client *c;
+
+       for(n = 0, c = nexttiled(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 = wh / (rows ? rows : 1);
+       cw = ww / (cols ? cols : 1);
+       for(i = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) {
+               cx = wx + (i / rows) * cw;
+               cy = wy + (i % rows) * ch;
+               /* adjust height/width of last row/column's windows */
+               ah = ((i + 1) % rows == 0) ? wh - ch * rows : 0;
+               aw = (i >= rows * (cols - 1)) ? ww - cw * cols : 0;
+               resize(c, cx, cy, cw - 2 * c->bw + aw, ch - 2 * c->bw + ah, 
False);
+               i++;
+       }
+}
+

Attachment: pgpnC5mPdY89x.pgp
Description: PGP signature

Reply via email to