summaryrefslogtreecommitdiffstats
path: root/dwl-patches/patches/barpadding/barpadding.patch
blob: e5cc185869a6750051793c6d8cdfcd6748a0b910 (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 f01cea73042155e856b2f41452724fe5c895eee4 Mon Sep 17 00:00:00 2001
From: sewn <sewn@disroot.org>
Date: Fri, 23 Aug 2024 09:59:03 +0300
Subject: [PATCH] add vertical and horizontal spacing to bar

https://dwm.suckless.org/patches/barpadding/
---
 config.def.h |  2 ++
 dwl.c        | 14 +++++++-------
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/config.def.h b/config.def.h
index 5d1dc2b..756b1ae 100644
--- a/config.def.h
+++ b/config.def.h
@@ -9,6 +9,8 @@ static const int bypass_surface_visibility = 0;  /* 1 means idle inhibitors will
 static const unsigned int borderpx         = 1;  /* border pixel of windows */
 static const int showbar                   = 1; /* 0 means no bar */
 static const int topbar                    = 1; /* 0 means bottom bar */
+static const int vertpad                   = 10; /* vertical padding of bar */
+static const int sidepad                   = 10; /* horizontal padding of bar */
 static const char *fonts[]                 = {"monospace:size=10"};
 static const float rootcolor[]             = COLOR(0x000000ff);
 /* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */
diff --git a/dwl.c b/dwl.c
index ece537a..380549a 100644
--- a/dwl.c
+++ b/dwl.c
@@ -598,8 +598,8 @@ arrangelayers(Monitor *m)
 		return;
 
 	if (m->scene_buffer->node.enabled) {
-		usable_area.height -= m->b.real_height;
-		usable_area.y += topbar ? m->b.real_height : 0;
+		usable_area.height -= m->b.real_height + vertpad;
+		usable_area.y += topbar ? m->b.real_height + vertpad : 0;
 	}
 
 	/* Arrange exclusive surfaces from top->bottom */
@@ -750,7 +750,7 @@ buttonpress(struct wl_listener *listener, void *data)
 		if (!c && !exclusive_focus &&
 			(node = wlr_scene_node_at(&layers[LyrBottom]->node, cursor->x, cursor->y, NULL, NULL)) &&
 			(buffer = wlr_scene_buffer_from_node(node)) && buffer == selmon->scene_buffer) {
-			cx = (cursor->x - selmon->m.x) * selmon->wlr_output->scale;
+			cx = (cursor->x - selmon->m.x - sidepad) * selmon->wlr_output->scale;
 			do
 				x += TEXTW(selmon, tags[i]);
 			while (cx >= x && ++i < LENGTH(tags));
@@ -1562,8 +1562,8 @@ drawbar(Monitor *m)
 
 	wlr_scene_buffer_set_dest_size(m->scene_buffer,
 		m->b.real_width, m->b.real_height);
-	wlr_scene_node_set_position(&m->scene_buffer->node, m->m.x,
-		m->m.y + (topbar ? 0 : m->m.height - m->b.real_height));
+	wlr_scene_node_set_position(&m->scene_buffer->node, m->m.x + sidepad,
+		m->m.y + (topbar ? vertpad : m->m.height - m->b.real_height - vertpad));
 	wlr_scene_buffer_set_buffer(m->scene_buffer, &buf->base);
 	wlr_buffer_unlock(&buf->base);
 }
@@ -3162,8 +3162,8 @@ updatebar(Monitor *m)
 	char fontattrs[12];
 
 	wlr_output_transformed_resolution(m->wlr_output, &rw, &rh);
-	m->b.width = rw;
-	m->b.real_width = (int)((float)m->b.width / m->wlr_output->scale);
+	m->b.width = rw - (2 * sidepad);
+	m->b.real_width = (int)((float)rw / m->wlr_output->scale) - (2 * sidepad);
 
 	wlr_scene_node_set_enabled(&m->scene_buffer->node, m->wlr_output->enabled ? showbar : 0);
 
-- 
2.46.0