aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.def.h2
-rw-r--r--dwl.c33
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 */
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++;
}