diff options
author | sinanmohd <sinan@firemail.cc> | 2023-09-22 14:55:35 +0530 |
---|---|---|
committer | sinanmohd <sinan@firemail.cc> | 2023-09-22 16:36:42 +0530 |
commit | 2dd280bbd70d032e940c41ffa738baadd6580c4d (patch) | |
tree | 8c714e3abcd2ddc312b2ac3f2fc6ecab89727983 | |
parent | b9a18f7a2f6b29f514169dd73930001661a6ee41 (diff) |
gaps: implement stable gaps
-rw-r--r-- | config.def.h | 2 | ||||
-rw-r--r-- | dwl.c | 33 |
2 files changed, 24 insertions, 11 deletions
diff --git a/config.def.h b/config.def.h index 8a16ea9..7c7e97f 100644 --- a/config.def.h +++ b/config.def.h @@ -2,6 +2,8 @@ static const int sloppyfocus = 1; /* focus follows mouse */ static const int bypass_surface_visibility = 0; /* 1 means idle inhibitors will disable idle tracking even if it's surface isn't visible */ static const unsigned int borderpx = 2; /* border pixel of windows */ +static const int monoclegaps = 1; /* 1 means gaps in monocle layout */ +static const unsigned int gap = 10; /* gap size */ static const float bordercolor[] = {0.27, 0.27, 0.27, 1.0}; static const float focuscolor[] = {0.0, 0.33, 0.47, 1.0}; /* To conform the xdg-protocol, set the alpha to zero to restore the old behavior */ @@ -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++; } |