diff options
author | Benjamin Chausse <benjamin@chausse.xyz> | 2024-01-26 18:09:26 -0500 |
---|---|---|
committer | Benjamin Chausse <benjamin@chausse.xyz> | 2024-01-26 18:09:26 -0500 |
commit | 5ea657380de0ea90acd52451c35d710a4072bc9d (patch) | |
tree | ec4ce16acf4c727d2f1172b2ba5dc009e4fe42b5 | |
parent | 74f81efa72bf93d9ea0b06f183f4d704dfd35543 (diff) |
Implement tilewide layout
-rw-r--r-- | config.def.h | 2 | ||||
-rw-r--r-- | dwm.c | 29 |
2 files changed, 31 insertions, 0 deletions
diff --git a/config.def.h b/config.def.h index 586dcb2..9c2b2c5 100644 --- a/config.def.h +++ b/config.def.h @@ -52,6 +52,7 @@ static const Layout layouts[] = { { "[M]", monocle }, { "|M|", centeredmaster }, { "TTT", bstack }, + { "[][]=", tilewide }, }; /* key definitions */ @@ -95,6 +96,7 @@ static const Key keys[] = { { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, { MODKEY, XK_u, setlayout, {.v = &layouts[3]} }, { MODKEY, XK_o, setlayout, {.v = &layouts[4]} }, + { MODKEY, XK_w, setlayout, {.v = &layouts[5]} }, { MODKEY, XK_space, setlayout, {0} }, { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, { MODKEY, XK_0, view, {.ui = ~0 } }, @@ -215,6 +215,7 @@ static void spawn(const Arg *arg); static void tag(const Arg *arg); static void tagmon(const Arg *arg); static void tile(Monitor *m); +static void tilewide(Monitor *m); static void togglebar(const Arg *arg); static void togglefloating(const Arg *arg); static void toggletag(const Arg *arg); @@ -1879,6 +1880,34 @@ tile(Monitor *m) } void +tilewide(Monitor *m) +{ + unsigned int i, n, w, h, mw, mx, ty; + Client *c; + + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + if (n == 0) + return; + + if (n > m->nmaster) + mw = m->nmaster ? m->ww * m->mfact : 0; + else + mw = m->ww; + for (i = mx = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if (i < m->nmaster) { + w = (mw - mx) / (MIN(n, m->nmaster) - i); + resize(c, m->wx + mx, m->wy, w - (2*c->bw), (m->wh - ty) - (2*c->bw), 0); + if (mx + WIDTH(c) < m->ww) + mx += WIDTH(c); + } else { + h = (m->wh - ty) / (n - i); + resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0); + if (ty + HEIGHT(c) < m->wh) + ty += HEIGHT(c); + } +} + +void togglebar(const Arg *arg) { selmon->showbar = !selmon->showbar; |