From 8e3aa607b638e7ad392af0d160196a577c21de2c Mon Sep 17 00:00:00 2001 From: 0undefined Date: Wed, 9 Apr 2025 10:53:37 +0200 Subject: Patch: hide vacant tags --- dwl.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/dwl.c b/dwl.c index 8bb8740..cbe9b1b 100644 --- a/dwl.c +++ b/dwl.c @@ -856,6 +856,7 @@ buttonpress(struct wl_listener *listener, void *data) Arg arg = {0}; Client *c; const Button *b; + uint32_t occ = 0; wlr_idle_notifier_v1_notify_activity(idle_notifier, seat); @@ -875,9 +876,22 @@ buttonpress(struct wl_listener *listener, void *data) (node = wlr_scene_node_at(&layers[LyrBottom]->node, cursor->x, cursor->y, NULL, NULL)) && (buffer = wlr_scene_buffer_from_node(node)) && buffer == selmon->scene_buffer) { cx = (cursor->x - selmon->m.x) * selmon->wlr_output->scale; - do + + // Get shown tags + wl_list_for_each(c, &clients, link) { + if (c->mon != selmon) + continue; + occ |= c->tags == TAGMASK ? 0 : c->tags; + } + + + do { + // Check if the tag is shown + if (!((occ & 1 << i) || selmon->tagset[selmon->seltags] & 1 << i)) + continue; + x += TEXTW(selmon, tags[i]); - while (cx >= x && ++i < LENGTH(tags)); + } while (cx >= x && ++i < LENGTH(tags)); if (i < LENGTH(tags)) { click = ClkTagBar; arg.ui = 1 << i; @@ -1897,20 +1911,18 @@ drawbar(Monitor *m) wl_list_for_each(c, &clients, link) { if (c->mon != m) continue; - occ |= c->tags; + occ |= c->tags == TAGMASK ? 0 : c->tags; if (c->isurgent) urg |= c->tags; } x = 0; c = focustop(m); for (i = 0; i < LENGTH(tags); i++) { + // Skip drawing this tag, if not in focus, or empty + if (!((occ & 1 << i) || m->tagset[m->seltags] & 1 << i)) continue; w = TEXTW(m, tags[i]); drwl_setscheme(m->drw, colors[m->tagset[m->seltags] & 1 << i ? SchemeTagSel : SchemeNorm]); drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, tags[i], urg & 1 << i); - if (occ & 1 << i) - drwl_rect(m->drw, x + boxs, boxs, boxw, boxw, - m == selmon && c && c->tags & 1 << i, - urg & 1 << i); x += w; } w = TEXTW(m, m->ltsymbol); -- cgit v1.3