apply vanitygaps to monocle

This commit is contained in:
frosty 2024-09-04 00:51:39 -04:00
parent 7db028d38a
commit f6fcb96c27

39
dwm.c
View file

@ -1195,16 +1195,49 @@ maprequest(XEvent *e)
void void
monocle(Monitor *m) monocle(Monitor *m)
{ {
unsigned int n = 0; unsigned int n = 0, oe = enablegaps;
Client *c; Client *c;
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
if (n == 0)
return;
if (smartgaps == n) {
oe = 0; // outer gaps disabled
}
n = 0;
for (c = m->clients; c; c = c->next) for (c = m->clients; c; c = c->next)
if (ISVISIBLE(c)) if (ISVISIBLE(c))
n++; n++;
if (n > 0) /* override layout symbol */ if (n > 0) /* override layout symbol */
snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n); snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
for (c = nexttiled(m->clients); c; c = nexttiled(c->next))
resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0); int newx, newy, neww, newh;
for (c = nexttiled(m->clients); c; c = nexttiled(c->next)) {
if (m->gappoh == 0) {
newx = m->wx - c->bw;
newy = m->wy - c->bw;
neww = m->ww;
newh = m->wh;
} else {
newx = m->wx + m->gappoh*oe - c->bw;
newy = m->wy + m->gappoh*oe - c->bw;
neww = m->ww - 2 * (m->gappoh*oe + c->bw);
newh = m->wh - 2 * (m->gappoh*oe + c->bw);
}
applysizehints(c, &newx, &newy, &neww, &newh, 0);
if (neww < m->ww) {
newx = m->wx + (m->ww - (neww + 2 * c->bw)) / 2;
}
if (newh < m->wh) {
newy = m->wy + (m->wh - (newh + 2 * c->bw)) / 2;
resize(c, newx, newy, neww, newh, 0);
}
}
} }
void void