fix centered master (always push on top of left side, at most jumble about the bottom one, not _all_ slaves)

This commit is contained in:
gutmet 2021-03-13 21:02:33 +01:00
parent c1ab4a2ab3
commit 8c08817097

10
dwm.c
View File

@ -499,13 +499,14 @@ buttonpress(XEvent *e)
void void
centeredmaster(Monitor *m) centeredmaster(Monitor *m)
{ {
unsigned int i, n, h, mw, mx, my, oty, ety, tw; unsigned int i, iSlave, n, nSlaves, h, mw, mx, my, oty, ety, tw;
Client *c; Client *c;
/* count number of clients in the selected monitor */ /* count number of clients in the selected monitor */
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
if (n == 0) if (n == 0)
return; return;
nSlaves = n - m->nmaster;
/* initialize areas */ /* initialize areas */
mw = m->ww; mw = m->ww;
@ -536,12 +537,13 @@ centeredmaster(Monitor *m)
my += HEIGHT(c); my += HEIGHT(c);
} else { } else {
/* stack clients are stacked vertically */ /* stack clients are stacked vertically */
if ((i - m->nmaster) % 2 ) { iSlave = i - m->nmaster;
h = (m->wh - ety) / ( (1 + n - i) / 2); if (iSlave < nSlaves/2) {
h = (m->wh - ety) / (nSlaves / 2 - iSlave);
resize(c, m->wx, m->wy + ety, tw - (2*c->bw), h - (2*c->bw), 0); resize(c, m->wx, m->wy + ety, tw - (2*c->bw), h - (2*c->bw), 0);
ety += HEIGHT(c); ety += HEIGHT(c);
} else { } else {
h = (m->wh - oty) / ((1 + n - i) / 2); h = (m->wh - oty) / (nSlaves - iSlave);
resize(c, m->wx + mx + mw, m->wy + oty, tw - (2*c->bw), h - (2*c->bw), 0); resize(c, m->wx + mx + mw, m->wy + oty, tw - (2*c->bw), h - (2*c->bw), 0);
oty += HEIGHT(c); oty += HEIGHT(c);
} }