diff options
author | Squibid <me@zacharyscheiman.com> | 2025-02-11 15:41:46 -0600 |
---|---|---|
committer | Squibid <me@zacharyscheiman.com> | 2025-02-11 15:41:46 -0600 |
commit | 082aa1edac6826731c5c0159f29037a3efd91afa (patch) | |
tree | d7d54951de40fcbc7e4dda101f4554d17ead8fe1 /dwl.c | |
parent | 398ec943214031a25e28ffddd1c0493e92373786 (diff) | |
download | dwl-082aa1edac6826731c5c0159f29037a3efd91afa.tar.gz dwl-082aa1edac6826731c5c0159f29037a3efd91afa.tar.bz2 dwl-082aa1edac6826731c5c0159f29037a3efd91afa.zip |
add uselessgaps patch
Diffstat (limited to 'dwl.c')
-rw-r--r-- | dwl.c | 52 |
1 files changed, 38 insertions, 14 deletions
@@ -205,6 +205,7 @@ struct Monitor { struct wlr_box w; /* window area, layout-relative */ struct wl_list layers[4]; /* LayerSurface.link */ const Layout *lt[2]; + int gappx; /* horizontal outer gaps */ unsigned int seltags; unsigned int sellt; uint32_t tagset[2]; @@ -356,6 +357,7 @@ static void tile(Monitor *m); static void togglebar(const Arg *arg); 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); @@ -426,6 +428,8 @@ static struct wlr_box sgeom; static struct wl_list mons; static Monitor *selmon; +static int enablegaps = 1; /* enables gaps, used by togglegaps */ + /* global event handlers */ static struct wl_listener cursor_axis = {.notify = axisnotify}; static struct wl_listener cursor_button = {.notify = buttonpress}; @@ -1076,9 +1080,9 @@ createmon(struct wl_listener *listener, void *data) for (i = 0; i < LENGTH(m->layers); i++) wl_list_init(&m->layers[i]); - wlr_output_state_init(&state); /* Initialize monitor state using configured rules */ + m->gappx = gappx; m->tagset[0] = m->tagset[1] = 1; for (r = monrules; r < END(monrules); r++) { if (!r->name || strstr(wlr_output->name, r->name)) { @@ -2031,12 +2035,16 @@ void monocle(Monitor *m) { Client *c; - int n = 0; + int n = 0, e = enablegaps; + + if (smartgaps == 1) { + e = 0; // outer gaps disabled + } wl_list_for_each(c, &clients, link) { if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen) continue; - resize(c, m->w, 0); + resize(c, (struct wlr_box){ .x = m->w.x + m->gappx*e, .y = m->w.y + m->gappx*e, .width = m->w.width - 2*m->gappx*e, .height = m->w.height - 2*m->gappx*e }, 0); n++; } if (n) @@ -2891,8 +2899,8 @@ tagmon(const Arg *arg) void tile(Monitor *m) { - unsigned int mw, my, ty; - int i, n = 0; + unsigned int h, r, e = enablegaps, mw, my, ty; + int i, n = 0; Client *c; wl_list_for_each(c, &clients, link) @@ -2901,22 +2909,31 @@ tile(Monitor *m) if (n == 0) return; + if (smartgaps == n) { + e = 0; // outer gaps disabled + } + if (n > m->nmaster) - mw = m->nmaster ? (int)roundf(m->w.width * m->mfact) : 0; + mw = m->nmaster ? (int)roundf((m->w.width + m->gappx*e) * m->mfact) : 0; else - mw = m->w.width; - i = my = ty = 0; + mw = m->w.width - 2*m->gappx*e + m->gappx*e; + i = 0; + my = ty = m->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 - m->gappx*e - m->gappx*e * (r - 1)) / r; + resize(c, (struct wlr_box){.x = m->w.x + m->gappx*e, .y = m->w.y + my, + .width = mw - m->gappx*e, .height = h}, 0); + my += c->geom.height + m->gappx*e; } 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 - m->gappx*e - m->gappx*e * (r - 1)) / r; + resize(c, (struct wlr_box){.x = m->w.x + mw + m->gappx*e, .y = m->w.y + ty, + .width = m->w.width - mw - 2*m->gappx*e, .height = h}, 0); + ty += c->geom.height + m->gappx*e; } i++; } @@ -2947,6 +2964,13 @@ togglefullscreen(const Arg *arg) } void +togglegaps(const Arg *arg) +{ + enablegaps = !enablegaps; + arrange(selmon); +} + +void toggletag(const Arg *arg) { uint32_t newtags; |