From ab7d28ff0f747eff6abc0dc460523c2d5c8f067a Mon Sep 17 00:00:00 2001 From: bakkeby Date: Tue, 27 Jun 2023 16:31:02 +0200 Subject: [PATCH] bar border - allow for the border size to be explicitly set ref. #364 --- config.def.h | 6 ++++++ dwm.c | 4 ++-- patch/setborderpx.c | 14 ++++++++------ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/config.def.h b/config.def.h index e75a22e..af32234 100644 --- a/config.def.h +++ b/config.def.h @@ -7,6 +7,12 @@ static const int corner_radius = 10; #else static const unsigned int borderpx = 1; /* border pixel of windows */ #endif // ROUNDED_CORNERS_PATCH +#if BAR_BORDER_PATCH +/* This allows the bar border size to be explicitly set separately from borderpx. + * If left as 0 then it will default to the borderpx value of the monitor and will + * automatically update with setborderpx. */ +static const unsigned int barborderpx = 0; /* border pixel of bar */ +#endif // BAR_BORDER_PATCH static const unsigned int snap = 32; /* snap pixel */ #if SWALLOW_PATCH static const int swallowfloating = 0; /* 1 means swallow floating windows by default */ diff --git a/dwm.c b/dwm.c index 269f965..2beb2a6 100644 --- a/dwm.c +++ b/dwm.c @@ -484,7 +484,7 @@ struct Monitor { int gappov; /* vertical outer gaps */ #endif // VANITYGAPS_PATCH #if SETBORDERPX_PATCH - unsigned int borderpx; + int borderpx; #endif // SETBORDERPX_PATCH unsigned int seltags; unsigned int sellt; @@ -1676,7 +1676,7 @@ createmon(void) bar->showbar = 1; bar->external = 0; #if BAR_BORDER_PATCH - bar->borderpx = borderpx; + bar->borderpx = (barborderpx ? barborderpx : borderpx); #else bar->borderpx = 0; #endif // BAR_BORDER_PATCH diff --git a/patch/setborderpx.c b/patch/setborderpx.c index 6cc0b34..250a939 100644 --- a/patch/setborderpx.c +++ b/patch/setborderpx.c @@ -15,13 +15,15 @@ setborderpx(const Arg *arg) int delta = 2 * (m->borderpx - prev_borderpx); #if BAR_BORDER_PATCH - for (bar = m->bar; bar; bar = bar->next) { - bar->bh = bar->bh - 2 * bar->borderpx + 2 * m->borderpx; - bar->borderpx = m->borderpx; + if (!barborderpx) { + for (bar = m->bar; bar; bar = bar->next) { + bar->bh = bar->bh - 2 * bar->borderpx + 2 * m->borderpx; + bar->borderpx = m->borderpx; + } + updatebarpos(m); + for (bar = m->bar; bar; bar = bar->next) + XMoveResizeWindow(dpy, bar->win, bar->bx, bar->by, bar->bw, bar->bh); } - updatebarpos(m); - for (bar = m->bar; bar; bar = bar->next) - XMoveResizeWindow(dpy, bar->win, bar->bx, bar->by, bar->bw, bar->bh); #endif // BAR_BORDER_PATCH for (c = m->clients; c; c = c->next) {