From bb0af060e558ece559b6e753ad3f4d0b50933775 Mon Sep 17 00:00:00 2001 From: Arthur Khachaturov Date: Thu, 1 Aug 2024 19:01:33 +0300 Subject: [PATCH] feat: hide vacant tags patch --- dwm.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/dwm.c b/dwm.c index bd04abd..7917e33 100644 --- a/dwm.c +++ b/dwm.c @@ -546,9 +546,14 @@ buttonpress(XEvent *e) i = 0; x = TEXTW(mwsymbol); - do + unsigned int occ = 0; + for(c = m->clients; c; c=c->next) + occ |= c->tags[metaws] == TAGMASK ? 0 : c->tags[metaws]; + do { + if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i)) + continue; x += TEXTW(tags[i]); - while (ev->x >= x && ++i < LENGTH(tags)); + } while (ev->x >= x && ++i < LENGTH(tags)); if (ev->x < TEXTW(mwsymbol)) click = ClkMwSymbol; @@ -839,7 +844,7 @@ drawbar(Monitor *m) } for (c = m->clients; c; c = c->next) { - occ |= c->tags[metaws]; + occ |= c->tags[metaws] == TAGMASK ? 0 : c->tags[metaws]; if (c->isurgent) urg |= c->tags[metaws]; } @@ -848,13 +853,14 @@ drawbar(Monitor *m) x = drw_text(drw, x, 0, w, bh, lrpad / 2, mwsymbol, 0); for (i = 0; i < LENGTH(tags); i++) { + if(!(occ & 1 << i || m->tagset[m->seltags] & 1 << i)) + continue; w = TEXTW(tags[i]); drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]); drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i); - if (occ & 1 << i) - drw_rect(drw, x + boxs, boxs, boxw, boxw, - m == selmon && selmon->sel && selmon->sel->tags[metaws] & 1 << i, - urg & 1 << i); + if (occ & 1 << i && m == selmon && + selmon->sel && selmon->sel->tags[metaws] & 1 << i) + drw_rect(drw, x + boxs, boxs, boxw, boxw, 1, urg & 1 << i); x += w; }