diff options
| author | Octavian Cerna <octavian.cerna@gmail.com> | 2015-01-16 11:48:41 +0200 |
|---|---|---|
| committer | Octavian Cerna <octavian.cerna@gmail.com> | 2015-01-16 11:48:41 +0200 |
| commit | 464d29436529979838e7886d51e18e2ad63629ff (patch) | |
| tree | da9cb4c1eb28c6f9926578811744f5495f050f39 | |
| parent | fea213cb9cce526f3f7a15d657b303b153010e2e (diff) | |
Add dwm-6.1-gaplessgrid.diffmyconfig
| -rw-r--r-- | config.h | 4 | ||||
| -rw-r--r-- | gaplessgrid.c | 35 |
2 files changed, 39 insertions, 0 deletions
@@ -47,11 +47,14 @@ static const float mfact = 0.55; /* factor of master area size [0.05..0.95] static const int nmaster = 1; /* number of clients in master area */ static const Bool resizehints = True; /* True means respect size hints in tiled resizals */ +#include "gaplessgrid.c" + static const Layout layouts[] = { /* symbol arrange function */ { "[]=", tile }, /* first entry is default */ { "><>", NULL }, /* no layout function means floating behavior */ { "[M]", monocle }, + { "###", gaplessgrid }, }; /* key definitions */ @@ -87,6 +90,7 @@ static Key keys[] = { { 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, XK_space, setlayout, {0} }, { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, { MODKEY, XK_0, view, {.ui = ~0 } }, diff --git a/gaplessgrid.c b/gaplessgrid.c new file mode 100644 index 0000000..10808c5 --- /dev/null +++ b/gaplessgrid.c @@ -0,0 +1,35 @@ +void +gaplessgrid(Monitor *m) { + unsigned int n, cols, rows, cn, rn, i, cx, cy, cw, ch; + Client *c; + + for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) ; + if(n == 0) + return; + + /* grid dimensions */ + for(cols = 0; cols <= n/2; cols++) + if(cols*cols >= n) + break; + if(n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */ + cols = 2; + rows = n/cols; + + /* window geometries */ + cw = cols ? m->ww / cols : m->ww; + cn = 0; /* current column number */ + rn = 0; /* current row number */ + for(i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) { + if(i/rows + 1 > cols - n%cols) + rows = n/cols + 1; + ch = rows ? m->wh / rows : m->wh; + cx = m->wx + cn*cw; + cy = m->wy + rn*ch; + resize(c, cx, cy, cw - 2 * c->bw, ch - 2 * c->bw, False); + rn++; + if(rn >= rows) { + rn = 0; + cn++; + } + } +} |
