From 2dd280bbd70d032e940c41ffa738baadd6580c4d Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Fri, 22 Sep 2023 14:55:35 +0530 Subject: gaps: implement stable gaps --- dwl.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'dwl.c') diff --git a/dwl.c b/dwl.c index cb9fd38..109ae26 100644 --- a/dwl.c +++ b/dwl.c @@ -926,6 +926,7 @@ createmon(struct wl_listener *listener, void *data) /* Initialize monitor state using configured rules */ for (i = 0; i < LENGTH(m->layers); i++) wl_list_init(&m->layers[i]); + m->tagset[0] = m->tagset[1] = 1; for (r = monrules; r < END(monrules); r++) { if (!r->name || strstr(wlr_output->name, r->name)) { @@ -1714,8 +1715,13 @@ monocle(Monitor *m) wl_list_for_each(c, &clients, link) { if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen) continue; - resize(c, m->w, 0); n++; + + if (!monoclegaps) + resize(c, m->w, 0); + else + resize(c, (struct wlr_box){.x = m->w.x + gap, .y = m->w.y + gap, + .width = m->w.width - 2 * gap, .height = m->w.height - 2 * gap}, 0); } if (n) snprintf(m->ltsymbol, LENGTH(m->ltsymbol), "[%d]", n); @@ -2449,7 +2455,7 @@ tagmon(const Arg *arg) void tile(Monitor *m) { - unsigned int i, n = 0, mw, my, ty; + unsigned int i, n = 0, h, r, mw, my, ty; Client *c; wl_list_for_each(c, &clients, link) @@ -2459,21 +2465,26 @@ tile(Monitor *m) return; if (n > m->nmaster) - mw = m->nmaster ? m->w.width * m->mfact : 0; + mw = m->nmaster ? (m->w.width + gap) * m->mfact : 0; else - mw = m->w.width; - i = my = ty = 0; + mw = m->w.width - gap; + i = 0; + my = ty = gap; wl_list_for_each(c, &clients, link) { if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen) continue; if (i < m->nmaster) { - resize(c, (struct wlr_box){.x = m->w.x, .y = m->w.y + my, .width = mw, - .height = (m->w.height - my) / (MIN(n, m->nmaster) - i)}, 0); - my += c->geom.height; + r = MIN(n, m->nmaster) - i; + h = (m->w.height - my - gap - gap * (r - 1)) / r; + resize(c, (struct wlr_box){.x = m->w.x + gap, .y = m->w.y + my, + .width = mw - gap, .height = h}, 0); + my += c->geom.height + gap; } else { - resize(c, (struct wlr_box){.x = m->w.x + mw, .y = m->w.y + ty, - .width = m->w.width - mw, .height = (m->w.height - ty) / (n - i)}, 0); - ty += c->geom.height; + r = n - i; + h = (m->w.height - ty - gap - gap * (r - 1)) / r; + resize(c, (struct wlr_box){.x = m->w.x + mw + gap, .y = m->w.y + ty, + .width = m->w.width - mw - 2*gap, .height = h}, 0); + ty += c->geom.height + gap; } i++; } -- cgit v1.2.3