2022-12-03 15:25:31 +01:00
|
|
|
int
|
|
|
|
width_tags(Bar *bar, BarWidthArg *a)
|
|
|
|
{
|
2022-12-04 22:20:17 +01:00
|
|
|
if (selmon->hidetags) {
|
2022-12-04 22:03:42 +01:00
|
|
|
return 0;
|
2022-12-04 22:20:17 +01:00
|
|
|
}
|
2022-12-04 22:03:42 +01:00
|
|
|
|
2022-12-03 15:25:31 +01:00
|
|
|
int w, i;
|
|
|
|
|
|
|
|
for (w = 0, i = 0; i < LENGTH(tags); i++) {
|
2022-12-05 17:30:52 +01:00
|
|
|
w += TEXTW(tags[i]);
|
2022-12-03 15:25:31 +01:00
|
|
|
}
|
2022-12-05 17:30:52 +01:00
|
|
|
return w;
|
2022-12-03 15:25:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
draw_tags(Bar *bar, BarDrawArg *a)
|
|
|
|
{
|
2022-12-04 22:20:17 +01:00
|
|
|
if (selmon->hidetags) {
|
2022-12-04 22:03:42 +01:00
|
|
|
return 0;
|
2022-12-04 22:20:17 +01:00
|
|
|
}
|
2022-12-04 22:03:42 +01:00
|
|
|
|
2022-12-03 15:25:31 +01:00
|
|
|
int invert;
|
2022-12-05 17:30:52 +01:00
|
|
|
int w, x = a->x;
|
2022-12-03 23:12:58 +01:00
|
|
|
int boxs = drw->font->h / 9;
|
|
|
|
int boxw = drw->font->h / 6 + 2;
|
2022-12-05 17:30:52 +01:00
|
|
|
unsigned int i, occ = 0, urg = 0;
|
|
|
|
Client *c;
|
|
|
|
Monitor *m = bar->mon;
|
2022-12-03 23:12:58 +01:00
|
|
|
|
2022-12-05 17:30:52 +01:00
|
|
|
for (c = m->clients; c; c = c->next) {
|
|
|
|
occ |= c->tags;
|
2022-12-03 15:25:31 +01:00
|
|
|
if (c->isurgent)
|
|
|
|
urg |= c->tags;
|
|
|
|
}
|
2022-12-05 17:30:52 +01:00
|
|
|
|
2022-12-03 15:25:31 +01:00
|
|
|
for (i = 0; i < LENGTH(tags); i++) {
|
|
|
|
invert = urg & 1 << i;
|
|
|
|
w = TEXTW(tags[i]);
|
2022-12-05 17:30:52 +01:00
|
|
|
drw_setscheme(drw, (m->tagset[m->seltags] & 1 << i ? tagscheme[i] : scheme[SchemeBar]));
|
2022-12-03 15:25:31 +01:00
|
|
|
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], invert, False);
|
2022-12-05 17:30:52 +01:00
|
|
|
if (occ & 1 << i)
|
|
|
|
drw_rect(drw, x + boxs, boxs, boxw, boxw,
|
|
|
|
m == selmon && selmon->sel && selmon->sel->tags & 1 << i, invert);
|
2022-12-03 15:25:31 +01:00
|
|
|
x += w;
|
|
|
|
}
|
2022-12-03 23:12:58 +01:00
|
|
|
|
2022-12-05 17:30:52 +01:00
|
|
|
return x;
|
2022-12-03 15:25:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
click_tags(Bar *bar, Arg *arg, BarClickArg *a)
|
|
|
|
{
|
2022-12-04 22:20:17 +01:00
|
|
|
if (selmon->hidetags) {
|
2022-12-04 22:03:42 +01:00
|
|
|
return 0;
|
2022-12-04 22:20:17 +01:00
|
|
|
}
|
2022-12-04 22:03:42 +01:00
|
|
|
|
2022-12-03 15:25:31 +01:00
|
|
|
int i = 0, x = lrpad / 2;
|
|
|
|
|
|
|
|
do {
|
2022-12-05 17:30:52 +01:00
|
|
|
x += TEXTW(tags[i]);
|
2022-12-03 15:25:31 +01:00
|
|
|
} while (a->rel_x >= x && ++i < LENGTH(tags));
|
|
|
|
if (i < LENGTH(tags)) {
|
|
|
|
arg->ui = 1 << i;
|
|
|
|
}
|
|
|
|
return ClkTagBar;
|
|
|
|
}
|