summaryrefslogtreecommitdiffstats
path: root/dwl-patches/patches/simpleborders/simpleborders-v0.7.patch
blob: e782d84751acc7f0bb9689af2fdaebc2da81029a (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
64
65
66
67
68
69
70
71
72
73
From 09759c3ef75158c366e9fc63814485fbb31a3ccf Mon Sep 17 00:00:00 2001
From: Ben Collerson <benc@benc.cc>
Date: Sat, 30 Dec 2023 13:39:31 +1000
Subject: [PATCH] simpleborders

---
 dwl.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/dwl.c b/dwl.c
index a2711f67..415fe1a0 100644
--- a/dwl.c
+++ b/dwl.c
@@ -259,6 +259,7 @@ static void closemon(Monitor *m);
 static void commitlayersurfacenotify(struct wl_listener *listener, void *data);
 static void commitnotify(struct wl_listener *listener, void *data);
 static void commitpopup(struct wl_listener *listener, void *data);
+static int countclients(Monitor *m);
 static void createdecoration(struct wl_listener *listener, void *data);
 static void createidleinhibitor(struct wl_listener *listener, void *data);
 static void createkeyboard(struct wlr_keyboard *keyboard);
@@ -308,6 +309,7 @@ static void motionnotify(uint32_t time, struct wlr_input_device *device, double
 		double sy, double sx_unaccel, double sy_unaccel);
 static void motionrelative(struct wl_listener *listener, void *data);
 static void moveresize(const Arg *arg);
+static int needsborder(Client *c);
 static void outputmgrapply(struct wl_listener *listener, void *data);
 static void outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int test);
 static void outputmgrtest(struct wl_listener *listener, void *data);
@@ -849,6 +851,17 @@ commitpopup(struct wl_listener *listener, void *data)
 	wl_list_remove(&listener->link);
 }
 
+int
+countclients(Monitor *m)
+{
+	unsigned int n = 0;
+	Client *c;
+	wl_list_for_each(c, &clients, link)
+		if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen)
+			n++;
+	return n;
+}
+
 void
 createdecoration(struct wl_listener *listener, void *data)
 {
@@ -1927,6 +1940,14 @@ moveresize(const Arg *arg)
 	}
 }
 
+int
+needsborder(Client *c) {
+	return ((countclients(c->mon) > 1
+			&& c->mon->lt[c->mon->sellt]->arrange != monocle)
+		|| c->isfloating)
+		&& !c->isfullscreen;
+}
+
 void
 outputmgrapply(struct wl_listener *listener, void *data)
 {
@@ -2190,6 +2211,7 @@ resize(Client *c, struct wlr_box geo, int interact)
 
 	client_set_bounds(c, geo.width, geo.height);
 	c->geom = geo;
+	c->bw = needsborder(c) ? borderpx : 0;
 	applybounds(c, bbox);
 
 	/* Update scene-graph, including borders */
-- 
2.45.2