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 /dwm.c | |
parent | 74f81efa72bf93d9ea0b06f183f4d704dfd35543 (diff) |
Implement tilewide layout
Diffstat (limited to 'dwm.c')
-rw-r--r-- | dwm.c | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -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; |