fix bug if hideemptytags is disabled in tags-powerline.c, add usedtags

to plain tags.c
This commit is contained in:
speedie 2022-12-06 18:08:12 +01:00
parent 5caaa4ad91
commit 050a8adb6b
2 changed files with 43 additions and 5 deletions

View file

@ -105,6 +105,9 @@ click_tags_pwl(Bar *bar, Arg *arg, BarClickArg *a)
if (selmon->hideemptytags) {
for (c = bar->mon->clients; c; c = c->next)
occ |= c->tags == 255 ? 0 : c->tags;
} else {
for (c = bar->mon->clients; c; c = c->next)
occ |= c->tags;
}
do {

View file

@ -6,9 +6,22 @@ width_tags(Bar *bar, BarWidthArg *a)
}
int w, i;
Client *c;
Monitor *m = bar->mon;
unsigned int occ = 0;
if (!selmon->hideemptytags) {
for (c = bar->mon->clients; c; c = c->next)
occ |= c->tags;
} else {
for (c = bar->mon->clients; c; c = c->next)
occ |= c->tags == 255 ? 0 : c->tags;
}
for (w = 0, i = 0; i < LENGTH(tags); i++) {
w += TEXTW(tags[i]);
if (!(occ & 1 << i || bar->mon->tagset[bar->mon->seltags] & 1 << i) && selmon->hideemptytags)
continue;
w += TEXTW(occ & 1 << i ? usedtags[i] : tags[i]);
}
return w;
}
@ -25,20 +38,30 @@ draw_tags(Bar *bar, BarDrawArg *a)
int boxs = drw->font->h / 9;
int boxw = drw->font->h / 6 + 2;
unsigned int i, occ = 0, urg = 0;
const char *tagtext;
Client *c;
Monitor *m = bar->mon;
for (c = m->clients; c; c = c->next) {
if (!selmon->hideemptytags) {
occ |= c->tags;
} else {
occ |= c->tags == 255 ? 0 : c->tags;
}
if (c->isurgent)
urg |= c->tags;
}
for (i = 0; i < LENGTH(tags); i++) {
if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i) && selmon->hideemptytags)
continue;
invert = urg & 1 << i;
w = TEXTW(tags[i]);
tagtext = occ & 1 << i ? usedtags[i] : tags[i];
w = TEXTW(tagtext);
drw_setscheme(drw, (m->tagset[m->seltags] & 1 << i ? tagscheme[i] : scheme[SchemeBar]));
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], invert, False);
drw_text(drw, x, 0, w, bh, lrpad / 2, tagtext, invert, False);
if (occ & 1 << i)
drw_rect(drw, x + boxs, boxs, boxw, boxw,
m == selmon && selmon->sel && selmon->sel->tags & 1 << i, invert);
@ -56,9 +79,21 @@ click_tags(Bar *bar, Arg *arg, BarClickArg *a)
}
int i = 0, x = lrpad / 2;
unsigned int occ = 0;
Client *c;
if (selmon->hideemptytags) {
for (c = bar->mon->clients; c; c = c->next)
occ |= c->tags == 255 ? 0 : c->tags;
} else {
for (c = bar->mon->clients; c; c = c->next)
occ |= c->tags;
}
do {
x += TEXTW(tags[i]);
if (!(occ & 1 << i || bar->mon->tagset[bar->mon->seltags] & 1 << i) && selmon->hideemptytags)
continue;
x += TEXTW(occ & 1 << i ? usedtags[i] : tags[i]);
} while (a->rel_x >= x && ++i < LENGTH(tags));
if (i < LENGTH(tags)) {
arg->ui = 1 << i;