1
0
mirror of https://github.com/alrayyes/dwm synced 2023-11-14 15:56:31 +00:00
dwm/local-gridmode-20170909-ceac8c9.diff

62 lines
2.4 KiB
Diff
Raw Normal View History

diff -up -N a/config.def.h b/config.def.h
--- a/config.def.h 2020-12-01 10:10:57.007393876 +0100
+++ b/config.def.h 2020-12-01 10:13:17.190767226 +0100
@@ -40,11 +40,13 @@ static const float mfact = 0.55; /*
2019-03-13 14:36:50 +00:00
static const int nmaster = 1; /* number of clients in master area */
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
+#include "layouts.c"
static const Layout layouts[] = {
/* symbol arrange function */
{ "[]=", tile }, /* first entry is default */
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
+ { "HHH", grid },
{ NULL, NULL },
2019-03-13 14:36:50 +00:00
};
@@ -81,6 +83,7 @@ static Key keys[] = {
2019-03-13 14:36:50 +00:00
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
+ { MODKEY, XK_g, setlayout, {.v = &layouts[3]} },
{ MODKEY|ControlMask, XK_comma, cyclelayout, {.i = -1 } },
{ MODKEY|ControlMask, XK_period, cyclelayout, {.i = +1 } },
2019-03-13 14:36:50 +00:00
{ MODKEY, XK_space, setlayout, {0} },
@@ -119,4 +122,3 @@ static Button buttons[] = {
{ ClkTagBar, MODKEY, Button1, tag, {0} },
{ ClkTagBar, MODKEY, Button3, toggletag, {0} },
};
-
diff -up -N a/layouts.c b/layouts.c
--- a/layouts.c 1970-01-01 01:00:00.000000000 +0100
+++ b/layouts.c 2020-12-01 10:14:11.740781107 +0100
2019-03-13 14:36:50 +00:00
@@ -0,0 +1,27 @@
+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++;
+ }
+}