summaryrefslogtreecommitdiffstats
path: root/dwl-patches/patches/mastercolumn/mastercolumn-gaps.patch
blob: 943c4bd63fcebca3b57b8291aeddf43fa938ca5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
From b6f2ee09778cdea8a1450d16bcf24a8a75e10b40 Mon Sep 17 00:00:00 2001
From: moe <moemmakki@gmail.com>
Date: Tue, 16 Jul 2024 13:56:24 -0400
Subject: [PATCH 1/1] add mastercolumn gaps

---
 dwl.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/dwl.c b/dwl.c
index b121094..be33c01 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1755,7 +1755,7 @@ unset_fullscreen:
 void
 mastercol(Monitor *m)
 {
-	unsigned int mw, mx, ty;
+	unsigned int h, w, r, e = m->gaps, mw, mx, ty;
 	int i, n = 0;
 	Client *c;
 
@@ -1764,23 +1764,30 @@ mastercol(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 = mx = ty = 0;
+	i = 0;
+	mx = 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 + mx, .y = m->w.y,
-				.width = (mw - mx) / (MIN(n, m->nmaster) - i), .height = m->w.height}, 0);
-			mx += c->geom.width;
+			r = MIN(n, m->nmaster) - i;
+			w = (mw - mx - gappx*e - gappx*e * (r - 1)) / r;
+			resize(c, (struct wlr_box){.x = m->w.x + mx, .y = m->w.y + gappx*e,
+				.width = w, .height = m->w.height - 2*gappx*e}, 0);
+			mx += c->geom.width + 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++;
 	}
-- 
2.45.2