diff --git a/config.def.h b/config.def.h index a8ee16e..7c8274a 100644 --- a/config.def.h +++ b/config.def.h @@ -9,6 +9,7 @@ static const unsigned int gappx = 15; static const unsigned int snap = 32; /* snap pixel */ static const int showbar = 1; /* 0 means no bar */ static const int showextrabar = 1; /* 0 means no bar */ +// TODO: FIX THAT SHIT static const int topbar = 1; /* 0 means bottom bar */ static const char statussep = ';'; static const int horizpadbar = 8; @@ -72,6 +73,7 @@ static const Layout layouts[] = { { "><>", NULL }, /* no layout function means floating behavior */ { "[M]", monocle }, { "HHH", grid }, + { "###", gaplessgrid }, }; /* key definitions */ @@ -128,6 +130,7 @@ static Key keys[] = { { SUPERKEY, XK_f, setlayout, {.v = &layouts[1]} }, { SUPERKEY, XK_m, setlayout, {.v = &layouts[2]} }, { SUPERKEY, XK_g, setlayout, {.v = &layouts[3]} }, + { SUPERKEY|ShiftMask, XK_g, setlayout, {.v = &layouts[4]} }, /* { SUPERKEY, XK_space, setlayout, {0} }, */ { SUPERKEY|ShiftMask, XK_space, togglefloating, {0} }, { SUPERKEY, XK_0, view, {.ui = ~0 } }, diff --git a/config.h b/config.h index 122ef86..7c8274a 100644 --- a/config.h +++ b/config.h @@ -9,6 +9,7 @@ static const unsigned int gappx = 15; static const unsigned int snap = 32; /* snap pixel */ static const int showbar = 1; /* 0 means no bar */ static const int showextrabar = 1; /* 0 means no bar */ +// TODO: FIX THAT SHIT static const int topbar = 1; /* 0 means bottom bar */ static const char statussep = ';'; static const int horizpadbar = 8; @@ -65,11 +66,14 @@ static const int nmaster = 1; /* number of clients in master area */ static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */ static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */ +#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 }, + { "###", gaplessgrid }, }; /* key definitions */ @@ -125,6 +129,8 @@ static Key keys[] = { { SUPERKEY, XK_t, setlayout, {.v = &layouts[0]} }, { SUPERKEY, XK_f, setlayout, {.v = &layouts[1]} }, { SUPERKEY, XK_m, setlayout, {.v = &layouts[2]} }, + { SUPERKEY, XK_g, setlayout, {.v = &layouts[3]} }, + { SUPERKEY|ShiftMask, XK_g, setlayout, {.v = &layouts[4]} }, /* { SUPERKEY, XK_space, setlayout, {0} }, */ { SUPERKEY|ShiftMask, XK_space, togglefloating, {0} }, { SUPERKEY, XK_0, view, {.ui = ~0 } }, diff --git a/dwm b/dwm index 8afaceb..54e625f 100755 Binary files a/dwm and b/dwm differ diff --git a/dwm.o b/dwm.o index 81fea48..bd37b13 100644 Binary files a/dwm.o and b/dwm.o differ diff --git a/layouts.c b/layouts.c index d26acf3..06fc554 100644 --- a/layouts.c +++ b/layouts.c @@ -25,3 +25,39 @@ grid(Monitor *m) { i++; } } + +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++; + } + } +}