commit 464f0be145387883d0667a778aa437c01a833177
parent fd484bb16536183ca294847bde6d33f0498db09f
Author: hhvn <dev@hhvn.uk>
Date: Thu, 30 Sep 2021 18:47:28 +0100
dwm.c: centeredmastered gaps between vertical stacks
Diffstat:
M | dwm.c | | | 45 | +++++++++++++++++++++++++-------------------- |
1 file changed, 25 insertions(+), 20 deletions(-)
diff --git a/dwm.c b/dwm.c
@@ -2305,7 +2305,7 @@ spiral(Monitor *mon) {
void
centeredmaster(Monitor *m)
{
- unsigned int i, n, h, mw, mx, my, oty, ety, tw;
+ unsigned int i, n, h, mw, mx, my, oty, ety, tw, mult;
Client *c;
/* count number of clients in the selected monitor */
@@ -2333,26 +2333,31 @@ centeredmaster(Monitor *m)
oty = 0;
ety = 0;
- for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
- if (i < m->nmaster) {
- /* nmaster clients are stacked vertically, in the center
- * of the screen */
- h = (m->wh - my) / (MIN(n, m->nmaster) - i);
- resize(c, m->wx + mx + gappx, m->wy + my + gappx, (mw - (2*c->bw)) - 2*gappx,
- (h - (2*c->bw)) - 2*gappx, 0);
- my += HEIGHT(c);
- } else {
- /* stack clients are stacked vertically */
- if ((i - m->nmaster) % 2 ) {
- h = (m->wh - ety) / ( (1 + n - i) / 2);
- resize(c, m->wx + gappx, m->wy + ety + gappx, tw - (2*c->bw) - gappx,
- (h - (2*c->bw)) - 2*gappx, 0);
- ety += HEIGHT(c);
+ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
+ if (i < m->nmaster) {
+ /* nmaster clients are stacked vertically, in the center
+ * of the screen */
+ mult = (i < m->nmaster - 1) ? 1 : 0;
+
+ h = (m->wh - my) / (MIN(n, m->nmaster) - i);
+ resize(c, m->wx + mx + gappx, m->wy + my + gappx, mw - 2*c->bw - 2*gappx,
+ h - 2*c->bw - (2+mult)*gappx, 0);
+ my += HEIGHT(c) + mult*gappx;
} else {
- h = (m->wh - oty) / ((1 + n - i) / 2);
- resize(c, m->wx + mx + mw, m->wy + oty + gappx,
- tw - (2*c->bw) - gappx, (h - (2*c->bw)) - 2*gappx, 0);
- oty += HEIGHT(c);
+ /* stack clients are stacked vertically */
+ mult = (i < n - 2) ? 1 : 0;
+
+ if ((i - m->nmaster) % 2 ) {
+ h = (m->wh - ety) / ( (1 + n - i) / 2);
+ resize(c, m->wx + gappx, m->wy + ety + gappx, tw - 2*c->bw - gappx,
+ h - 2*c->bw - (2+mult)*gappx, 0);
+ ety += HEIGHT(c) + mult*gappx;
+ } else {
+ h = (m->wh - oty) / ((1 + n - i) / 2);
+ resize(c, m->wx + mx + mw, m->wy + oty + gappx,
+ tw - 2*c->bw - gappx, h - 2*c->bw - (2+mult)*gappx, 0);
+ oty += HEIGHT(c) + mult*gappx;
+ }
}
}
}