dwm-hide_vacant_tags-6.2.diff (1489B)
1 diff --git a/dwm.c b/dwm.c 2 index 4465af1..c4aa3de 100644 3 --- a/dwm.c 4 +++ b/dwm.c 5 @@ -416,7 +416,7 @@ attachstack(Client *c) 6 void 7 buttonpress(XEvent *e) 8 { 9 - unsigned int i, x, click; 10 + unsigned int i, x, click, occ = 0; 11 Arg arg = {0}; 12 Client *c; 13 Monitor *m; 14 @@ -431,9 +431,14 @@ buttonpress(XEvent *e) 15 } 16 if (ev->window == selmon->barwin) { 17 i = x = 0; 18 - do 19 + for (c = m->clients; c; c = c->next) 20 + occ |= c->tags == 255 ? 0 : c->tags; 21 + do { 22 + /* do not reserve space for vacant tags */ 23 + if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i)) 24 + continue; 25 x += TEXTW(tags[i]); 26 - while (ev->x >= x && ++i < LENGTH(tags)); 27 + } while (ev->x >= x && ++i < LENGTH(tags)); 28 if (i < LENGTH(tags)) { 29 click = ClkTagBar; 30 arg.ui = 1 << i; 31 @@ -709,19 +714,19 @@ drawbar(Monitor *m) 32 } 33 34 for (c = m->clients; c; c = c->next) { 35 - occ |= c->tags; 36 + occ |= c->tags == 255 ? 0 : c->tags; 37 if (c->isurgent) 38 urg |= c->tags; 39 } 40 x = 0; 41 for (i = 0; i < LENGTH(tags); i++) { 42 + /* do not draw vacant tags */ 43 + if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i)) 44 + continue; 45 + 46 w = TEXTW(tags[i]); 47 drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]); 48 drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i); 49 - if (occ & 1 << i) 50 - drw_rect(drw, x + boxs, boxs, boxw, boxw, 51 - m == selmon && selmon->sel && selmon->sel->tags & 1 << i, 52 - urg & 1 << i); 53 x += w; 54 } 55 w = blw = TEXTW(m->ltsymbol);