From 537bd7c485c1fb370d7a73f979ee140dab9c078e Mon Sep 17 00:00:00 2001 From: sewn Date: Mon, 25 Mar 2024 00:15:01 +0300 Subject: [PATCH] port barpadding patch to bar for dwl --- config.def.h | 3 +++ dwl.c | 14 +++++++++----- 2 files changed, 12 insertions(+), 5 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 976fefb..6650fdc 100644 --- a/dwl.c +++ b/dwl.c @@ -434,6 +434,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; @@ -571,8 +573,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 */ @@ -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); } @@ -2747,6 +2749,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); @@ -3087,7 +3091,7 @@ updatebardims(Monitor *m) { int rw, rh; wlr_output_transformed_resolution(m->wlr_output, &rw, &rh); - m->b.width = rw; + m->b.width = rw - 2 * sp; m->b.height = bh; } -- 2.44.0