Added gaps in monocle mode

This commit is contained in:
Fernando 2021-11-01 13:28:30 -07:00
parent 78f68cecc3
commit 3b5454254c

35
dwm.c
View File

@ -1111,18 +1111,47 @@ 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)) int newx, newy, neww, newh;
resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
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
motionnotify(XEvent *e) motionnotify(XEvent *e)
{ {