diff options
| author | bakkeby <[email protected]> | 2021-11-23 22:36:53 +0100 |
|---|---|---|
| committer | bakkeby <[email protected]> | 2021-11-23 22:36:53 +0100 |
| commit | 63fed59d19ee51f8f8d2876425817e099cb57b04 (patch) | |
| tree | 43aca0765a77909733534051c83b7be622a9c0b9 /patch | |
| parent | c7af5c6b67cf2f09439050f635684a42a879c446 (diff) | |
| download | dwm-flexipatch-63fed59d19ee51f8f8d2876425817e099cb57b04.tar.gz dwm-flexipatch-63fed59d19ee51f8f8d2876425817e099cb57b04.zip | |
Adding taglabels patch ref. #199
Diffstat (limited to 'patch')
| -rw-r--r-- | patch/bar_taglabels.c | 87 | ||||
| -rw-r--r-- | patch/bar_taglabels.h | 5 | ||||
| -rw-r--r-- | patch/include.c | 3 | ||||
| -rw-r--r-- | patch/include.h | 3 |
4 files changed, 98 insertions, 0 deletions
diff --git a/patch/bar_taglabels.c b/patch/bar_taglabels.c new file mode 100644 index 0000000..f9c3cf8 --- /dev/null +++ b/patch/bar_taglabels.c @@ -0,0 +1,87 @@ +int +width_taglabels(Bar *bar, BarArg *a) +{ + int w, i; + Client *c; + Monitor *m = bar->mon; + char *icon; + unsigned int occ = 0; + + for (c = m->clients; c; c = c->next) + occ |= c->tags == 255 ? 0 : c->tags; + + for (w = 0, i = 0; i < NUMTAGS; i++) { + m->taglabel[i][0] = '\0'; + #if BAR_HIDEVACANTTAGS_PATCH + if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i)) + continue; + #endif // BAR_HIDEVACANTTAGS_PATCH + icon = tagicon(m, i); + XClassHint ch = { NULL, NULL }; + for (c = m->clients; c; c = c->next) { + if (c->tags & (1 << i)) { + XGetClassHint(dpy, c->win, &ch); + break; + } + } + if (ch.res_class) { + if (lcaselbl) + ch.res_class[0] = tolower(ch.res_class[0]); + snprintf(m->taglabel[i], 64, ptagf, icon, ch.res_class); + } else + snprintf(m->taglabel[i], 64, etagf, icon); + + w += TEXTW(m->taglabel[i]); + } + return w; +} + +int +draw_taglabels(Bar *bar, BarArg *a) +{ + int invert = 0; + int w, x = a->x; + unsigned int i, occ = 0, urg = 0; + Client *c; + Monitor *m = bar->mon; + + for (c = m->clients; c; c = c->next) + if (c->isurgent) + urg |= c->tags; + + for (i = 0; i < NUMTAGS; i++) { + /* do not draw vacant tags */ + if (!m->taglabel[i][0]) + continue; + drw_setscheme(drw, scheme[ + m->tagset[m->seltags] & 1 << i + ? SchemeTagsSel + : urg & 1 << i + ? SchemeUrg + : SchemeTagsNorm + ]); + w = TEXTW(m->taglabel[i]); + drw_text(drw, x, a->y, w, a->h, lrpad / 2, m->taglabel[i], invert, False); + drawindicator(m, NULL, occ, x, a->y, w, a->h, i, -1, invert, tagindicatortype); + x += w; + } + + return 1; +} + +int +click_taglabels(Bar *bar, Arg *arg, BarArg *a) +{ + int i = 0, x = lrpad / 2; + Monitor *m = bar->mon; + + do { + if (!m->taglabel[i][0]) + continue; + x += TEXTW(m->taglabel[i]); + } while (a->x >= x && ++i < NUMTAGS); + if (i < NUMTAGS) { + arg->ui = 1 << i; + } + return ClkTagBar; +} diff --git a/patch/bar_taglabels.h b/patch/bar_taglabels.h new file mode 100644 index 0000000..57250f9 --- /dev/null +++ b/patch/bar_taglabels.h @@ -0,0 +1,5 @@ +#include <ctype.h> /* for making tab label lowercase, very tiny standard library */ + +static int width_taglabels(Bar *bar, BarArg *a); +static int draw_taglabels(Bar *bar, BarArg *a); +static int click_taglabels(Bar *bar, Arg *arg, BarArg *a);
\ No newline at end of file diff --git a/patch/include.c b/patch/include.c index 29dac83..d47c6fd 100644 --- a/patch/include.c +++ b/patch/include.c @@ -56,6 +56,9 @@ #if BAR_TAGS_PATCH #include "bar_tags.c" #endif +#if BAR_TAGLABELS_PATCH +#include "bar_taglabels.c" +#endif #if BAR_TAGGRID_PATCH #include "bar_taggrid.c" #endif diff --git a/patch/include.h b/patch/include.h index eea37a8..f26f36e 100644 --- a/patch/include.h +++ b/patch/include.h @@ -56,6 +56,9 @@ #if BAR_TAGS_PATCH #include "bar_tags.h" #endif +#if BAR_TAGLABELS_PATCH +#include "bar_taglabels.h" +#endif #if BAR_TAGGRID_PATCH #include "bar_taggrid.h" #endif |
