From 0752076e881bae3320840e071ed394e51d8133dc Mon Sep 17 00:00:00 2001 From: speedie Date: Mon, 5 Dec 2022 17:30:52 +0100 Subject: [PATCH] rename _basic tags to simply tags. powerlined now end with _powerline --- bar.h | 3 +- bar/items.c | 2 +- bar/items.h | 2 +- bar/tags-basic.c | 67 ------------------------- bar/tags-basic.h | 3 -- bar/tags-powerline.c | 117 +++++++++++++++++++++++++++++++++++++++++++ bar/tags-powerline.h | 3 ++ bar/tags.c | 80 ++++++----------------------- 8 files changed, 139 insertions(+), 138 deletions(-) delete mode 100644 bar/tags-basic.c delete mode 100644 bar/tags-basic.h create mode 100644 bar/tags-powerline.c create mode 100644 bar/tags-powerline.h diff --git a/bar.h b/bar.h index 9757ac0..296ec7d 100644 --- a/bar.h +++ b/bar.h @@ -13,7 +13,8 @@ static const BarRule barrules[] = { /* monitor bar alignment width function draw function click function name */ { -1, 0, bar_align_left, width_ltsymbol, draw_ltsymbol, click_ltsymbol, "layout" }, - { -1, 0, bar_align_left, width_tags, draw_tags, click_tags, "tags" }, + //{ -1, 0, bar_align_left, width_tags, draw_tags, click_tags, "tags" }, + { -1, 0, bar_align_left, width_tags_pwl, draw_tags_pwl, click_tags_pwl, "powerline tags" }, { 'A', 0, bar_align_right, width_systray, draw_systray, click_systray, "systray" }, //{ 'A', 0, bar_align_right, width_status_basic, draw_status_basic, click_status_basic, "basic status" }, { 'A', 0, bar_align_right, width_status, draw_status, click_status, "clickable status" }, diff --git a/bar/items.c b/bar/items.c index 9721214..cafbd7b 100644 --- a/bar/items.c +++ b/bar/items.c @@ -1,7 +1,7 @@ #include "../toggle.h" /* Include what we've included */ +#include "tags-powerline.c" /* Include powerline tags */ #include "tags.c" /* Include tags */ -#include "tags-basic.c" /* Include basic tags */ #include "layoutindicator.c" /* Include layout indicator */ #include "statusbar.c" /* Include status bar with status2d and clickstatus */ #include "statusbar-basic.c" /* Include basic status bar */ diff --git a/bar/items.h b/bar/items.h index 874ec82..92013c3 100644 --- a/bar/items.h +++ b/bar/items.h @@ -1,5 +1,5 @@ #include "../toggle.h" -#include "tags-basic.h" +#include "tags-powerline.h" #include "tags.h" #include "layoutindicator.h" #include "statusbar.h" diff --git a/bar/tags-basic.c b/bar/tags-basic.c deleted file mode 100644 index 24639d0..0000000 --- a/bar/tags-basic.c +++ /dev/null @@ -1,67 +0,0 @@ -int -width_tags_basic(Bar *bar, BarWidthArg *a) -{ - if (selmon->hidetags) { - return 0; - } - - int w, i; - - for (w = 0, i = 0; i < LENGTH(tags); i++) { - w += TEXTW(tags[i]); - } - return w; -} - -int -draw_tags_basic(Bar *bar, BarDrawArg *a) -{ - if (selmon->hidetags) { - return 0; - } - - int invert; - int w, x = a->x; - int boxs = drw->font->h / 9; - int boxw = drw->font->h / 6 + 2; - unsigned int i, occ = 0, urg = 0; - Client *c; - Monitor *m = bar->mon; - - for (c = m->clients; c; c = c->next) { - occ |= c->tags; - if (c->isurgent) - urg |= c->tags; - } - - for (i = 0; i < LENGTH(tags); i++) { - invert = urg & 1 << i; - w = TEXTW(tags[i]); - 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); - if (occ & 1 << i) - drw_rect(drw, x + boxs, boxs, boxw, boxw, - m == selmon && selmon->sel && selmon->sel->tags & 1 << i, invert); - x += w; - } - - return x; -} - -int -click_tags_basic(Bar *bar, Arg *arg, BarClickArg *a) -{ - if (selmon->hidetags) { - return 0; - } - - int i = 0, x = lrpad / 2; - - do { - x += TEXTW(tags[i]); - } while (a->rel_x >= x && ++i < LENGTH(tags)); - if (i < LENGTH(tags)) { - arg->ui = 1 << i; - } - return ClkTagBar; -} diff --git a/bar/tags-basic.h b/bar/tags-basic.h deleted file mode 100644 index d98b6ca..0000000 --- a/bar/tags-basic.h +++ /dev/null @@ -1,3 +0,0 @@ -static int width_tags_basic(Bar *bar, BarWidthArg *a); -static int draw_tags_basic(Bar *bar, BarDrawArg *a); -static int click_tags_basic(Bar *bar, Arg *arg, BarClickArg *a); diff --git a/bar/tags-powerline.c b/bar/tags-powerline.c new file mode 100644 index 0000000..fbd88e3 --- /dev/null +++ b/bar/tags-powerline.c @@ -0,0 +1,117 @@ +int +width_tags_pwl(Bar *bar, BarWidthArg *a) +{ + if (selmon->hidetags) { + return 0; + } + + int w, i; + unsigned int occ = 0; + int plw = drw->font->h / 2 + 1; + Client *c; + + if (selmon->hideemptytags) { + 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++) { + if (!(occ & 1 << i || bar->mon->tagset[bar->mon->seltags] & 1 << i) && selmon->hideemptytags) + continue; + w += TEXTW(tags[i]) + plw; + } + return w + lrpad; +} + +int +draw_tags_pwl(Bar *bar, BarDrawArg *a) +{ + if (selmon->hidetags) { + return 0; + } + + int x, w; + int invert; + int plw = drw->font->h / 2 + 1; + unsigned int i, occ = 0, urg = 0; + Client *c; + Clr *prevscheme, *nxtscheme; + int boxs = drw->font->h / 9; + int boxw = drw->font->h / 6 + 2; + + for (c = bar->mon->clients; c; c = c->next) { + if (selmon->hideemptytags) + occ |= c->tags == 255 ? 0 : c->tags; + else + occ |= c->tags; + + if (c->isurgent) + urg |= c->tags; + } + x = a->x; + prevscheme = scheme[SchemeBar]; + for (i = 0; i < LENGTH(tags); i++) { + /* do not draw vacant tags */ + if (!(occ & 1 << i || bar->mon->tagset[bar->mon->seltags] & 1 << i) && selmon->hideemptytags) + continue; + invert = urg & 1 << i; + w = TEXTW(tags[i]); + + if (urg & 1 << i && allowurgent) + drw_settrans(drw, prevscheme, (nxtscheme = scheme[bar->mon->tagset[bar->mon->seltags] & 1 << i ? SchemeTagsSel : SchemeTagsUrg])); + else + drw_settrans(drw, prevscheme, (nxtscheme = (bar->mon->tagset[bar->mon->seltags] & 1 << i ? tagscheme[i] : scheme[SchemeTagsNorm]))); + + if (selmon->tagplshape) + drw_arrow(drw, x, 0, plw, bh, 1, 1); + else + drw_arrow(drw, x, 0, plw, bh, 1, 0); + + x += plw; + drw_setscheme(drw, nxtscheme); + drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], invert, False); + if (occ & 1 << i && !selmon->hideemptytags) + drw_rect(drw, x + boxs, boxs, boxw, boxw, bar->mon == selmon && selmon->sel && selmon->sel->tags & 1 << i, invert); + + x += w; + prevscheme = nxtscheme; + } + nxtscheme = scheme[SchemeBar]; + + drw_settrans(drw, prevscheme, nxtscheme); + + if (selmon->tagplshape) + drw_arrow(drw, x, 0, plw, bh, 1, 1); + else + drw_arrow(drw, x, 0, plw, bh, 1, 0); + + return a->x + a->w; +} + +int +click_tags_pwl(Bar *bar, Arg *arg, BarClickArg *a) +{ + if (selmon->hidetags) { + return 0; + } + + int i = 0, x = lrpad / 2; + int plw = drw->font->h / 2 + 1; + 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; + } + + do { + if (!(occ & 1 << i || bar->mon->tagset[bar->mon->seltags] & 1 << i) && selmon->hideemptytags) + continue; + x += TEXTW(tags[i]) + plw; + } while (a->rel_x >= x && ++i < LENGTH(tags)); + if (i < LENGTH(tags)) { + arg->ui = 1 << i; + } + return ClkTagBar; +} diff --git a/bar/tags-powerline.h b/bar/tags-powerline.h new file mode 100644 index 0000000..ff4ce8b --- /dev/null +++ b/bar/tags-powerline.h @@ -0,0 +1,3 @@ +static int width_tags_pwl(Bar *bar, BarWidthArg *a); +static int draw_tags_pwl(Bar *bar, BarDrawArg *a); +static int click_tags_pwl(Bar *bar, Arg *arg, BarClickArg *a); diff --git a/bar/tags.c b/bar/tags.c index 0c3d1e3..7c46aaf 100644 --- a/bar/tags.c +++ b/bar/tags.c @@ -6,21 +6,11 @@ width_tags(Bar *bar, BarWidthArg *a) } int w, i; - unsigned int occ = 0; - int plw = drw->font->h / 2 + 1; - Client *c; - - if (selmon->hideemptytags) { - 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++) { - if (!(occ & 1 << i || bar->mon->tagset[bar->mon->seltags] & 1 << i) && selmon->hideemptytags) - continue; - w += TEXTW(tags[i]) + plw; + w += TEXTW(tags[i]); } - return w + lrpad; + return w; } int @@ -30,62 +20,32 @@ draw_tags(Bar *bar, BarDrawArg *a) return 0; } - int x, w; int invert; - int plw = drw->font->h / 2 + 1; - unsigned int i, occ = 0, urg = 0; - Client *c; - Clr *prevscheme, *nxtscheme; + int w, x = a->x; int boxs = drw->font->h / 9; int boxw = drw->font->h / 6 + 2; + unsigned int i, occ = 0, urg = 0; + Client *c; + Monitor *m = bar->mon; - for (c = bar->mon->clients; c; c = c->next) { - if (selmon->hideemptytags) - occ |= c->tags == 255 ? 0 : c->tags; - else - occ |= c->tags; - + for (c = m->clients; c; c = c->next) { + occ |= c->tags; if (c->isurgent) urg |= c->tags; } - x = a->x; - prevscheme = scheme[SchemeBar]; + for (i = 0; i < LENGTH(tags); i++) { - /* do not draw vacant tags */ - if (!(occ & 1 << i || bar->mon->tagset[bar->mon->seltags] & 1 << i) && selmon->hideemptytags) - continue; invert = urg & 1 << i; w = TEXTW(tags[i]); - - if (urg & 1 << i && allowurgent) - drw_settrans(drw, prevscheme, (nxtscheme = scheme[bar->mon->tagset[bar->mon->seltags] & 1 << i ? SchemeTagsSel : SchemeTagsUrg])); - else - drw_settrans(drw, prevscheme, (nxtscheme = (bar->mon->tagset[bar->mon->seltags] & 1 << i ? tagscheme[i] : scheme[SchemeTagsNorm]))); - - if (selmon->tagplshape) - drw_arrow(drw, x, 0, plw, bh, 1, 1); - else - drw_arrow(drw, x, 0, plw, bh, 1, 0); - - x += plw; - drw_setscheme(drw, nxtscheme); + 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); - if (occ & 1 << i && !selmon->hideemptytags) - drw_rect(drw, x + boxs, boxs, boxw, boxw, bar->mon == selmon && selmon->sel && selmon->sel->tags & 1 << i, invert); - + if (occ & 1 << i) + drw_rect(drw, x + boxs, boxs, boxw, boxw, + m == selmon && selmon->sel && selmon->sel->tags & 1 << i, invert); x += w; - prevscheme = nxtscheme; } - nxtscheme = scheme[SchemeBar]; - drw_settrans(drw, prevscheme, nxtscheme); - - if (selmon->tagplshape) - drw_arrow(drw, x, 0, plw, bh, 1, 1); - else - drw_arrow(drw, x, 0, plw, bh, 1, 0); - - return a->x + a->w; + return x; } int @@ -96,19 +56,9 @@ click_tags(Bar *bar, Arg *arg, BarClickArg *a) } int i = 0, x = lrpad / 2; - int plw = drw->font->h / 2 + 1; - 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; - } do { - if (!(occ & 1 << i || bar->mon->tagset[bar->mon->seltags] & 1 << i) && selmon->hideemptytags) - continue; - x += TEXTW(tags[i]) + plw; + x += TEXTW(tags[i]); } while (a->rel_x >= x && ++i < LENGTH(tags)); if (i < LENGTH(tags)) { arg->ui = 1 << i;