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
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;
/* count number of clients in the selected monitor */
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
if (n == 0)
return;
nSlaves = n - m->nmaster;
/* initialize areas */
mw = m->ww;
@ -536,12 +537,13 @@ centeredmaster(Monitor *m)
my += HEIGHT(c);
} else {
/* stack clients are stacked vertically */
if ((i - m->nmaster) % 2 ) {
h = (m->wh - ety) / ( (1 + n - i) / 2);
iSlave = i - m->nmaster;
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);
ety += HEIGHT(c);
} 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);
oty += HEIGHT(c);
}