From 46ebaea58f121a33ed0d3ea07f40cfb70c9de2f9 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Sat, 22 Aug 2020 20:30:51 +0200 Subject: [PATCH] Added clientindicators patch and unified and simplified indicator code. Enabled centeredwindowname option for awesomebar and bartabgroups patches. --- patch/bar_indicators.c | 66 ++++++++++++++++++++++++++++++++++++++++++ patch/bar_indicators.h | 10 +++++++ 2 files changed, 76 insertions(+) create mode 100644 patch/bar_indicators.c create mode 100644 patch/bar_indicators.h diff --git a/patch/bar_indicators.c b/patch/bar_indicators.c new file mode 100644 index 0000000..863923e --- /dev/null +++ b/patch/bar_indicators.c @@ -0,0 +1,66 @@ +/* Indicator properties, you can override these in your config.h if you want. */ +#ifndef TAGSINDICATOR +#define TAGSINDICATOR 1 // 0 = off, 1 = on if >1 client/view tag, 2 = always on +#endif +#ifndef TAGSPX +#define TAGSPX 5 // # pixels for tag grid boxes +#endif +#ifndef TAGSROWS +#define TAGSROWS 3 // # rows in tag grid (9 tags, e.g. 3x3) +#endif + +void +drawindicator(Monitor *m, Client *c, unsigned int occ, int x, int w, unsigned int tag, int filled, int invert, int type) +{ + int i, boxw, boxs, indn = 0; + if (!(occ & 1 << tag)) + return; + + boxs = drw->fonts->h / 9; + boxw = drw->fonts->h / 6 + 2; + if (filled == -1) + filled = m == selmon && m->sel && m->sel->tags & 1 << tag; + + switch (type) { + default: + case INDICATOR_TOP_LEFT_SQUARE: + drw_rect(drw, x + boxs, boxs, boxw, boxw, filled, invert); + break; + case INDICATOR_TOP_LEFT_LARGER_SQUARE: + drw_rect(drw, x + boxs + 2, boxs+1, boxw+1, boxw+1, filled, invert); + break; + case INDICATOR_TOP_BAR: + drw_rect(drw, x + boxw, 0, w - ( 2 * boxw + 1), boxw/2, filled, invert); + break; + case INDICATOR_BOTTOM_BAR: + drw_rect(drw, x + boxw, bh - boxw/2, w - ( 2 * boxw + 1), boxw/2, 1, invert); + break; + case INDICATOR_CLIENT_DOTS: + for (c = m->clients; c; c = c->next) { + if (c->tags & (1 << tag)) { + drw_rect(drw, x, 1 + (indn * 2), m->sel == c ? 6 : 1, 1, 1, invert); + indn++; + } + if (bh <= 1 + (indn * 2)) { + indn = 0; + x += 2; + } + } + break; + case INDICATOR_RIGHT_TAGS: + if (!c) + break; + for (i = 0; i < LENGTH(tags); i++) { + drw_rect(drw, + ( x + w - 2 - ((LENGTH(tags) / TAGSROWS) * TAGSPX) + - (i % (LENGTH(tags)/TAGSROWS)) + ((i % (LENGTH(tags) / TAGSROWS)) * TAGSPX) + ), + ( 2 + ((i / (LENGTH(tags)/TAGSROWS)) * TAGSPX) + - ((i / (LENGTH(tags)/TAGSROWS))) + ), + TAGSPX, TAGSPX, (c->tags >> i) & 1, 0 + ); + } + break; + } +} \ No newline at end of file diff --git a/patch/bar_indicators.h b/patch/bar_indicators.h new file mode 100644 index 0000000..cd1d259 --- /dev/null +++ b/patch/bar_indicators.h @@ -0,0 +1,10 @@ +enum { + INDICATOR_TOP_LEFT_SQUARE, + INDICATOR_TOP_LEFT_LARGER_SQUARE, + INDICATOR_TOP_BAR, + INDICATOR_BOTTOM_BAR, + INDICATOR_CLIENT_DOTS, + INDICATOR_RIGHT_TAGS +}; + +static void drawindicator(Monitor *m, Client *c, unsigned int occ, int x, int w, unsigned int tag, int filled, int invert, int type); \ No newline at end of file