dwm-alttagsdecoration-2020010304-cb3f58a.diff (1998B)
1 diff --git a/config.def.h b/config.def.h 2 index 1c0b587..d4b11fc 100644 3 --- a/config.def.h 4 +++ b/config.def.h 5 @@ -20,6 +20,7 @@ static const char *colors[][3] = { 6 7 /* tagging */ 8 static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; 9 +static const char *alttags[] = { "<01>", "<02>", "<03>", "<04>", "<05>" }; 10 11 static const Rule rules[] = { 12 /* xprop(1): 13 diff --git a/dwm.c b/dwm.c 14 index 4465af1..a394159 100644 15 --- a/dwm.c 16 +++ b/dwm.c 17 @@ -416,7 +416,7 @@ attachstack(Client *c) 18 void 19 buttonpress(XEvent *e) 20 { 21 - unsigned int i, x, click; 22 + unsigned int i, x, click, occ; 23 Arg arg = {0}; 24 Client *c; 25 Monitor *m; 26 @@ -430,9 +430,13 @@ buttonpress(XEvent *e) 27 focus(NULL); 28 } 29 if (ev->window == selmon->barwin) { 30 - i = x = 0; 31 + i = x = occ = 0; 32 + /* Bitmask of occupied tags */ 33 + for (c = m->clients; c; c = c->next) 34 + occ |= c->tags; 35 + 36 do 37 - x += TEXTW(tags[i]); 38 + x += TEXTW(occ & 1 << i ? alttags[i] : tags[i]); 39 while (ev->x >= x && ++i < LENGTH(tags)); 40 if (i < LENGTH(tags)) { 41 click = ClkTagBar; 42 @@ -699,6 +703,7 @@ drawbar(Monitor *m) 43 int boxs = drw->fonts->h / 9; 44 int boxw = drw->fonts->h / 6 + 2; 45 unsigned int i, occ = 0, urg = 0; 46 + const char *tagtext; 47 Client *c; 48 49 /* draw status first so it can be overdrawn by tags later */ 50 @@ -715,13 +720,10 @@ drawbar(Monitor *m) 51 } 52 x = 0; 53 for (i = 0; i < LENGTH(tags); i++) { 54 - w = TEXTW(tags[i]); 55 - drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]); 56 - drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i); 57 - if (occ & 1 << i) 58 - drw_rect(drw, x + boxs, boxs, boxw, boxw, 59 - m == selmon && selmon->sel && selmon->sel->tags & 1 << i, 60 - urg & 1 << i); 61 + tagtext = occ & 1 << i ? alttags[i] : tags[i]; 62 + w = TEXTW(tagtext); 63 + drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]); 64 + drw_text(drw, x, 0, w, bh, lrpad / 2, tagtext, urg & 1 << i); 65 x += w; 66 } 67 w = blw = TEXTW(m->ltsymbol);