diff options
| author | Raghuram Subramani <raghus2247@gmail.com> | 2024-10-08 22:58:52 +0530 |
|---|---|---|
| committer | Raghuram Subramani <raghus2247@gmail.com> | 2024-10-08 22:58:52 +0530 |
| commit | f999acff8fb732bea747ba9e64622de33dd52290 (patch) | |
| tree | b04e43b77445a7c6819b72edad4a6bf6b7a39eff /dwl.c | |
| parent | bde1652317027761b103566578d7974768c5d059 (diff) | |
(patch): gaps.patch
Diffstat (limited to '')
| -rw-r--r-- | dwl.c | 34 |
1 files changed, 26 insertions, 8 deletions
@@ -202,6 +202,7 @@ struct Monitor { struct wlr_box w; /* window area, layout-relative */ struct wl_list layers[4]; /* LayerSurface.link */ const Layout *lt[2]; + int gaps; Pertag *pertag; unsigned int seltags; unsigned int sellt; @@ -343,6 +344,7 @@ static void tagmon(const Arg *arg); static void tile(Monitor *m); static void togglefloating(const Arg *arg); static void togglefullscreen(const Arg *arg); +static void togglegaps(const Arg *arg); static void toggletag(const Arg *arg); static void toggleview(const Arg *arg); static void unlocksession(struct wl_listener *listener, void *data); @@ -1037,6 +1039,8 @@ createmon(struct wl_listener *listener, void *data) wlr_output_state_init(&state); /* Initialize monitor state using configured rules */ + m->gaps = gaps; + m->tagset[0] = m->tagset[1] = 1; for (r = monrules; r < END(monrules); r++) { if (!r->name || strstr(wlr_output->name, r->name)) { @@ -2733,7 +2737,7 @@ tagmon(const Arg *arg) void tile(Monitor *m) { - unsigned int mw, my, ty; + unsigned int h, r, e = m->gaps, mw, my, ty; int i, n = 0; Client *c; @@ -2742,23 +2746,30 @@ tile(Monitor *m) n++; if (n == 0) return; + if (smartgaps == n) + e = 0; if (n > m->nmaster) - mw = m->nmaster ? (int)roundf(m->w.width * m->mfact) : 0; + mw = m->nmaster ? (int)roundf((m->w.width + gappx*e) * m->mfact) : 0; else mw = m->w.width; - i = my = ty = 0; + i = 0; + my = ty = gappx*e; 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 - gappx*e - gappx*e * (r - 1)) / r; + resize(c, (struct wlr_box){.x = m->w.x + gappx*e, .y = m->w.y + my, + .width = mw - 2*gappx*e, .height = h}, 0); + my += c->geom.height + gappx*e; } else { + r = n - i; + h = (m->w.height - ty - gappx*e - gappx*e * (r - 1)) / r; 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; + .width = m->w.width - mw - gappx*e, .height = h}, 0); + ty += c->geom.height + gappx*e; } i++; } @@ -2782,6 +2793,13 @@ togglefullscreen(const Arg *arg) } void +togglegaps(const Arg *arg) +{ + selmon->gaps = !selmon->gaps; + arrange(selmon); +} + +void toggletag(const Arg *arg) { uint32_t newtags; |
