dwl-patches/patches/barborder/barborder.patch
A Frederick Christensen 9c5d5d85f3
dwl-patches overhaul
Eliminated wiki.
Individual patches have a README.md explanation in their own subdirectory.
Simplified submission of new patches and maintenance of existing patches.
Instructions page (README.md autodisplayed) is now at https://codeberg.org/dwl/dwl-patches/
2024-05-09 23:12:04 -05:00

129 lines
4.4 KiB
Diff

From 38dd71e51784ab68261d9c0479a4579d419315f1 Mon Sep 17 00:00:00 2001
From: sewn <sewn@disroot.org>
Date: Sun, 14 Apr 2024 08:47:04 +0300
Subject: [PATCH] add border to bar
---
config.def.h | 3 ++-
dwl.c | 27 ++++++++++++++++-----------
2 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/config.def.h b/config.def.h
index 0be3ad0..e5e595a 100644
--- a/config.def.h
+++ b/config.def.h
@@ -6,7 +6,7 @@
/* appearance */
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 unsigned int borderpx = 1; /* border pixel of windows & bar */
static const float rootcolor[] = COLOR(0x000000ff);
static const float bordercolor[] = COLOR(0x444444ff);
static const float focuscolor[] = COLOR(0x005577ff);
@@ -19,6 +19,7 @@ static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */
static const char *fonts[] = {"monospace:size=10"};
static const char *fontattrs = "dpi=96";
+static pixman_color_t borderbar = { 0x5555, 0x7777, 0x0000, 0xffff };
static pixman_color_t normbarfg = { 0xbbbb, 0xbbbb, 0xbbbb, 0xffff };
static pixman_color_t normbarbg = { 0x2222, 0x2222, 0x2222, 0xffff };
static pixman_color_t selbarfg = { 0xeeee, 0xeeee, 0xeeee, 0xffff };
diff --git a/dwl.c b/dwl.c
index 54273ae..3153bfd 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1344,7 +1344,8 @@ dirtomon(enum wlr_direction dir)
void
drawbar(Monitor *mon)
{
- int x, w, tw = 0;
+ int x, y = borderpx, w, tw = 0;
+ int mh, mw;
int sel;
int boxs = font->height / 9;
int boxw = font->height / 6 + 2;
@@ -1357,6 +1358,8 @@ drawbar(Monitor *mon)
if (!mon || !mon->showbar)
return;
+ mh = mon->b.height - borderpx * 2;
+ mw = mon->b.width - borderpx * 2;
stride = mon->b.width * 4;
size = stride * mon->b.height;
@@ -1367,12 +1370,14 @@ drawbar(Monitor *mon)
pix = pixman_image_create_bits(
PIXMAN_a8r8g8b8, mon->b.width, mon->b.height, buf->data, stride);
+ drwl_rect(pix, 0, 0, mon->b.width, mon->b.height, 1, &borderbar);
+
/* draw status first so it can be overdrawn by tags later */
if (mon == selmon) {
if (stext[0] == '\0')
strncpy(stext, "dwl-"VERSION, sizeof(stext));
tw = TEXTW(stext) - lrpad;
- drwl_text(pix, font, mon->b.width - tw, 0, tw, mon->b.height, 0,
+ drwl_text(pix, font, borderpx + mw - tw, y, tw, mh, 0,
stext, &normbarfg, &normbarbg);
}
@@ -1384,37 +1389,37 @@ drawbar(Monitor *mon)
urg |= c->tags;
}
c = focustop(mon);
- x = 0;
+ x = borderpx;
for (i = 0; i < LENGTH(tags); i++) {
w = TEXTW(tags[i]);
sel = mon->tagset[mon->seltags] & 1 << i;
- drwl_text(pix, font, x, 0, w, mon->b.height, lrpad / 2, tags[i],
+ drwl_text(pix, font, x, y, w, mh, lrpad / 2, tags[i],
urg & 1 << i ? &selbarbg : (sel ? &selbarfg : &normbarfg),
urg & 1 << i ? &selbarfg : (sel ? &selbarbg : &normbarbg));
if (occ & 1 << i)
- drwl_rect(pix, x + boxs, boxs, boxw, boxw, sel,
+ drwl_rect(pix, x + boxs, y + boxs, boxw, boxw, sel,
urg & 1 << i ? &selbarbg : (sel ? &selbarfg : &normbarfg));
x += w;
}
w = TEXTW(mon->ltsymbol);
- x = drwl_text(pix, font, x, 0, w, mon->b.height, lrpad / 2,
+ x = drwl_text(pix, font, x, y, w, mh, lrpad / 2,
mon->ltsymbol, &normbarfg, &normbarbg);
- if ((w = mon->b.width - tw - x) > mon->b.height) {
+ if ((w = mw - tw - x + borderpx) > mh) {
if (c != NULL) {
- drwl_text(pix, font, x, 0, w, mon->b.height, lrpad / 2,
+ drwl_text(pix, font, x, y, w, mh, lrpad / 2,
c ? client_get_title(c) : NULL,
mon == selmon ? &selbarfg : &normbarfg,
(mon == selmon && c) ? &selbarbg : &normbarbg);
if (c && c->isfloating)
- drwl_rect(pix, x + boxs, boxs, boxw, boxw, 0,
+ drwl_rect(pix, x + boxs, y + boxs, boxw, boxw, 0,
mon == selmon ? &selbarfg : &normbarfg);
} else {
- drwl_rect(pix, x, 0, w, mon->b.height, 1, &normbarbg);
+ drwl_rect(pix, x, y, w, mh, 1, &normbarbg);
}
}
@@ -2664,7 +2669,7 @@ setup(void)
die("Could not load font");
lrpad = font->height;
- bh = font->height + 2;
+ bh = font->height + 2 + borderpx * 2;
status_event_source = wl_event_loop_add_fd(wl_display_get_event_loop(dpy),
STDIN_FILENO, WL_EVENT_READABLE, status_in, NULL);
--
2.44.0