diff --git a/patches/barborder/README.md b/patches/barborder/README.md index 576db06..9400fc7 100644 --- a/patches/barborder/README.md +++ b/patches/barborder/README.md @@ -3,7 +3,7 @@ Add a border around the [bar](https://codeberg.org/dwl/dwl-patches/wiki/bar) similar to how a client is given a border. ### Download -- [2024-06-03](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/barborder/barborder.patch) (bar 2024-05-28) +- [2024-06-10](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/barborder/barborder.patch) (bar 2024-06-10) ### Authors - [sewn](https://codeberg.org/sewn) diff --git a/patches/barborder/barborder.patch b/patches/barborder/barborder.patch index 3f8db69..c616dd1 100644 --- a/patches/barborder/barborder.patch +++ b/patches/barborder/barborder.patch @@ -1,6 +1,6 @@ -From aea34ede12983a37aef3ff5a90ba6214fa2db797 Mon Sep 17 00:00:00 2001 +From 1589ba9e16216e13dcc77e08b638f86ba41d47eb Mon Sep 17 00:00:00 2001 From: sewn -Date: Mon, 3 Jun 2024 10:27:42 +0300 +Date: Mon, 10 Jun 2024 14:59:12 +0300 Subject: [PATCH] add border to bar --- @@ -9,7 +9,7 @@ Subject: [PATCH] add border to bar 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/config.def.h b/config.def.h -index 0be3ad0..e5e595a 100644 +index d0bb5bc..9387dea 100644 --- a/config.def.h +++ b/config.def.h @@ -6,7 +6,7 @@ @@ -21,65 +21,65 @@ index 0be3ad0..e5e595a 100644 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 */ +@@ -18,6 +18,7 @@ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You ca + 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 0268772..96e03ec 100644 +index cd484bd..679409f 100644 --- a/dwl.c +++ b/dwl.c -@@ -1344,7 +1344,8 @@ dirtomon(enum wlr_direction dir) +@@ -1349,7 +1349,8 @@ dirtomon(enum wlr_direction dir) void - drawbar(Monitor *mon) + drawbar(Monitor *m) { - 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) + int boxs = m->font->height / 9; + int boxw = m->font->height / 6 + 2; +@@ -1362,6 +1363,8 @@ drawbar(Monitor *m) + if (!m->showbar) return; -+ mh = mon->b.height - borderpx * 2; -+ mw = mon->b.width - borderpx * 2; - stride = mon->b.width * 4; - size = stride * mon->b.height; ++ mh = m->b.height - borderpx * 2; ++ mw = m->b.width - borderpx * 2; + stride = m->b.width * 4; + size = stride * m->b.height; -@@ -1367,12 +1370,14 @@ drawbar(Monitor *mon) +@@ -1372,12 +1375,14 @@ drawbar(Monitor *m) pix = pixman_image_create_bits( - PIXMAN_a8r8g8b8, mon->b.width, mon->b.height, buf->data, stride); + PIXMAN_a8r8g8b8, m->b.width, m->b.height, buf->data, stride); -+ drwl_rect(pix, 0, 0, mon->b.width, mon->b.height, 1, &borderbar); ++ drwl_rect(pix, 0, 0, m->b.width, m->b.height, 1, &borderbar); + /* draw status first so it can be overdrawn by tags later */ - if (mon == selmon) { + if (m == 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, + tw = TEXTW(m, stext) - m->lrpad; +- drwl_text(pix, m->font, m->b.width - tw, 0, tw, m->b.height, 0, ++ drwl_text(pix, m->font, borderpx + mw - tw, y, tw, mh, 0, stext, &normbarfg, &normbarbg); } -@@ -1384,37 +1389,37 @@ drawbar(Monitor *mon) +@@ -1388,37 +1393,37 @@ drawbar(Monitor *m) + if (c->isurgent) 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; + w = TEXTW(m, tags[i]); + sel = m->tagset[m->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], +- drwl_text(pix, m->font, x, 0, w, m->b.height, m->lrpad / 2, tags[i], ++ drwl_text(pix, m->font, x, y, w, mh, m->lrpad / 2, tags[i], urg & 1 << i ? &selbarbg : (sel ? &selbarfg : &normbarfg), urg & 1 << i ? &selbarfg : (sel ? &selbarbg : &normbarbg)); @@ -91,38 +91,38 @@ index 0268772..96e03ec 100644 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); + w = TEXTW(m, m->ltsymbol); +- x = drwl_text(pix, m->font, x, 0, w, m->b.height, m->lrpad / 2, ++ x = drwl_text(pix, m->font, x, y, w, mh, m->lrpad / 2, + m->ltsymbol, &normbarfg, &normbarbg); -- if ((w = mon->b.width - tw - x) > mon->b.height) { +- if ((w = m->b.width - tw - x) > m->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, + if ((c = focustop(m)) != NULL) { +- drwl_text(pix, m->font, x, 0, w, m->b.height, m->lrpad / 2, ++ drwl_text(pix, m->font, x, y, w, mh, m->lrpad / 2, client_get_title(c), - mon == selmon ? &selbarfg : &normbarfg, - (mon == selmon && c) ? &selbarbg : &normbarbg); + m == selmon ? &selbarfg : &normbarfg, + (m == 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); + m == selmon ? &selbarfg : &normbarfg); } else -- drwl_rect(pix, x, 0, w, mon->b.height, 1, &normbarbg); +- drwl_rect(pix, x, 0, w, m->b.height, 1, &normbarbg); + drwl_rect(pix, x, y, w, mh, 1, &normbarbg); } pixman_image_unref(pix); -@@ -2663,7 +2668,7 @@ setup(void) - die("Could not load font"); +@@ -3020,7 +3025,7 @@ updatebar(Monitor *m) - lrpad = font->height; -- bh = font->height + 2; -+ bh = font->height + 2 + borderpx * 2; + m->b.scale = m->wlr_output->scale; + m->lrpad = m->font->height; +- m->b.height = m->font->height + 2; ++ m->b.height = m->font->height + 2 + borderpx * 2; + m->b.real_height = (int)((float)m->b.height / m->wlr_output->scale); + } - status_event_source = wl_event_loop_add_fd(wl_display_get_event_loop(dpy), - STDIN_FILENO, WL_EVENT_READABLE, status_in, NULL); -- 2.45.0