dwl-patches/bar/barpadding.patch
2024-03-23 19:21:10 +03:00

97 lines
3.4 KiB
Diff

From 213d041523e36b7e4f8f2f527eb044bc2d3e9d3d Mon Sep 17 00:00:00 2001
From: sewn <sewn@disroot.org>
Date: Tue, 19 Mar 2024 00:19:39 +0300
Subject: [PATCH] port barpadding patch to bar for dwl
---
config.def.h | 3 +++
dwl.c | 16 ++++++++++------
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/config.def.h b/config.def.h
index bd008c9..a2cf167 100644
--- a/config.def.h
+++ b/config.def.h
@@ -7,6 +7,7 @@
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 = 1; /* border pixel of windows */
+
static const float rootcolor[] = COLOR(0x000000ff);
static const float bordercolor[] = COLOR(0x444444ff);
static const float focuscolor[] = COLOR(0x005577ff);
@@ -17,6 +18,8 @@ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You ca
/* bar */
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 char *fontattrs = "dpi=96";
static pixman_color_t normbarfg = { 0xbbbb, 0xbbbb, 0xbbbb, 0xffff };
diff --git a/dwl.c b/dwl.c
index 8341134..51ce9f0 100644
--- a/dwl.c
+++ b/dwl.c
@@ -433,6 +433,8 @@ static Monitor *selmon;
static struct fcft_font *font;
static int bh;
+static int vp;
+static int sp;
static int lrpad;
static char stext[256];
static struct wl_event_source *status_event_source;
@@ -570,8 +572,8 @@ arrangelayers(Monitor *m)
return;
if (m->showbar) {
- usable_area.height -= m->b.height;
- usable_area.y += topbar ? m->b.height : 0;
+ usable_area.height = usable_area.height - vertpad - m->b.height;
+ usable_area.y = topbar ? usable_area.y + m->b.height + vp : usable_area.y;
}
/* Arrange exclusive surfaces from top->bottom */
@@ -1018,7 +1020,7 @@ createmon(struct wl_listener *listener, void *data)
m->scene_buffer = wlr_scene_buffer_create(layers[LyrBottom], NULL);
m->scene_buffer->point_accepts_input = bar_accepts_input;
- m->b.width = m->wlr_output->width;
+ m->b.width = m->wlr_output->width - 2 * sp;
m->b.height = bh;
m->showbar = showbar;
@@ -1501,8 +1503,8 @@ drawbar(Monitor *mon)
}
pixman_image_unref(pix);
- wlr_scene_node_set_position(&mon->scene_buffer->node, mon->m.x,
- mon->m.y + (topbar ? 0 : mon->m.height - mon->b.height));
+ wlr_scene_node_set_position(&mon->scene_buffer->node, mon->m.x + sp,
+ mon->m.y + vp + (topbar ? 0 : mon->m.height - mon->b.height));
wlr_scene_buffer_set_buffer(mon->scene_buffer, &buf->base);
wlr_buffer_drop(&buf->base);
}
@@ -2756,6 +2758,8 @@ setup(void)
lrpad = font->height;
bh = font->height + 2;
+ sp = sidepad;
+ vp = (topbar == 1) ? vertpad : - vertpad;
status_event_source = wl_event_loop_add_fd(wl_display_get_event_loop(dpy),
STDIN_FILENO, WL_EVENT_READABLE, status_in, NULL);
@@ -3077,7 +3081,7 @@ updatemons(struct wl_listener *listener, void *data)
/* Update bar */
wl_list_for_each(m, &mons, link) {
- m->b.width = m->wlr_output->width;
+ m->b.width = m->wlr_output->width - 2 * sp;
m->b.height = bh;
drawbar(m);
}
--
2.44.0