fix bug if hideemptytags is disabled in tags-powerline.c, add usedtags
to plain tags.c
This commit is contained in:
parent
5caaa4ad91
commit
050a8adb6b
|
@ -105,6 +105,9 @@ click_tags_pwl(Bar *bar, Arg *arg, BarClickArg *a)
|
||||||
if (selmon->hideemptytags) {
|
if (selmon->hideemptytags) {
|
||||||
for (c = bar->mon->clients; c; c = c->next)
|
for (c = bar->mon->clients; c; c = c->next)
|
||||||
occ |= c->tags == 255 ? 0 : c->tags;
|
occ |= c->tags == 255 ? 0 : c->tags;
|
||||||
|
} else {
|
||||||
|
for (c = bar->mon->clients; c; c = c->next)
|
||||||
|
occ |= c->tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
45
bar/tags.c
45
bar/tags.c
|
@ -6,9 +6,22 @@ width_tags(Bar *bar, BarWidthArg *a)
|
||||||
}
|
}
|
||||||
|
|
||||||
int w, i;
|
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++) {
|
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;
|
return w;
|
||||||
}
|
}
|
||||||
|
@ -25,20 +38,30 @@ draw_tags(Bar *bar, BarDrawArg *a)
|
||||||
int boxs = drw->font->h / 9;
|
int boxs = drw->font->h / 9;
|
||||||
int boxw = drw->font->h / 6 + 2;
|
int boxw = drw->font->h / 6 + 2;
|
||||||
unsigned int i, occ = 0, urg = 0;
|
unsigned int i, occ = 0, urg = 0;
|
||||||
|
const char *tagtext;
|
||||||
Client *c;
|
Client *c;
|
||||||
Monitor *m = bar->mon;
|
Monitor *m = bar->mon;
|
||||||
|
|
||||||
for (c = m->clients; c; c = c->next) {
|
for (c = m->clients; c; c = c->next) {
|
||||||
occ |= c->tags;
|
if (!selmon->hideemptytags) {
|
||||||
|
occ |= c->tags;
|
||||||
|
} else {
|
||||||
|
occ |= c->tags == 255 ? 0 : c->tags;
|
||||||
|
}
|
||||||
|
|
||||||
if (c->isurgent)
|
if (c->isurgent)
|
||||||
urg |= c->tags;
|
urg |= c->tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < LENGTH(tags); i++) {
|
for (i = 0; i < LENGTH(tags); i++) {
|
||||||
|
if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i) && selmon->hideemptytags)
|
||||||
|
continue;
|
||||||
|
|
||||||
invert = urg & 1 << i;
|
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_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)
|
if (occ & 1 << i)
|
||||||
drw_rect(drw, x + boxs, boxs, boxw, boxw,
|
drw_rect(drw, x + boxs, boxs, boxw, boxw,
|
||||||
m == selmon && selmon->sel && selmon->sel->tags & 1 << i, invert);
|
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;
|
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 {
|
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));
|
} while (a->rel_x >= x && ++i < LENGTH(tags));
|
||||||
if (i < LENGTH(tags)) {
|
if (i < LENGTH(tags)) {
|
||||||
arg->ui = 1 << i;
|
arg->ui = 1 << i;
|
||||||
|
|
Loading…
Reference in a new issue