dwm-clientindicatorshidevacant-6.2.diff - sites - public wiki contents of suckless.org
 (HTM) git clone git://git.suckless.org/sites
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
       dwm-clientindicatorshidevacant-6.2.diff (2391B)
       ---
            1 From 166fe643c650defe3b9b18367969dd1359775e0b Mon Sep 17 00:00:00 2001
            2 From: Miles Alan <m@milesalan.com>
            3 Date: Mon, 17 Aug 2020 21:46:14 -0500
            4 Subject: [PATCH] Combination of the clientindicators & hidevacant patches
            5 
            6 The clientindicator patch draws a dot indicator overlayed on each tag icon
            7 for each client. The selected client is drawn as a larger horizontal line.
            8 
            9 The hidevacant patch hides tags which have no clients.
           10 ---
           11  dwm.c | 31 +++++++++++++++++++++++--------
           12  1 file changed, 23 insertions(+), 8 deletions(-)
           13 
           14 diff --git a/dwm.c b/dwm.c
           15 index 4465af1..969b129 100644
           16 --- a/dwm.c
           17 +++ b/dwm.c
           18 @@ -416,7 +416,7 @@ attachstack(Client *c)
           19  void
           20  buttonpress(XEvent *e)
           21  {
           22 -        unsigned int i, x, click;
           23 +        unsigned int i, x, click, occ = 0;
           24          Arg arg = {0};
           25          Client *c;
           26          Monitor *m;
           27 @@ -431,9 +431,14 @@ buttonpress(XEvent *e)
           28          }
           29          if (ev->window == selmon->barwin) {
           30                  i = x = 0;
           31 -                do
           32 +                for (c = m->clients; c; c = c->next)
           33 +                        occ |= c->tags == 255 ? 0 : c->tags;
           34 +                do {
           35 +                        /* do not reserve space for vacant tags */
           36 +                        if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
           37 +                                continue;
           38                          x += TEXTW(tags[i]);
           39 -                while (ev->x >= x && ++i < LENGTH(tags));
           40 +                } while (ev->x >= x && ++i < LENGTH(tags));
           41                  if (i < LENGTH(tags)) {
           42                          click = ClkTagBar;
           43                          arg.ui = 1 << i;
           44 @@ -695,6 +700,7 @@ dirtomon(int dir)
           45  void
           46  drawbar(Monitor *m)
           47  {
           48 +        int indn;
           49          int x, w, sw = 0;
           50          int boxs = drw->fonts->h / 9;
           51          int boxw = drw->fonts->h / 6 + 2;
           52 @@ -709,19 +715,28 @@ drawbar(Monitor *m)
           53          }
           54  
           55          for (c = m->clients; c; c = c->next) {
           56 -                occ |= c->tags;
           57 +                occ |= c->tags == 255 ? 0 : c->tags;
           58                  if (c->isurgent)
           59                          urg |= c->tags;
           60          }
           61          x = 0;
           62          for (i = 0; i < LENGTH(tags); i++) {
           63 +                /* do not draw vacant tags */
           64 +                if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
           65 +                continue;
           66 +
           67 +                indn = 0;
           68                  w = TEXTW(tags[i]);
           69                  drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
           70                  drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
           71 -                if (occ & 1 << i)
           72 -                        drw_rect(drw, x + boxs, boxs, boxw, boxw,
           73 -                                m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
           74 -                                urg & 1 << i);
           75 +
           76 +                for (c = m->clients; c; c = c->next) {
           77 +                        if (c->tags & (1 << i)) {
           78 +                                drw_rect(drw, x, 1 + (indn * 2), selmon->sel == c ? 6 : 1, 1, 1, urg & 1 << i);
           79 +                                indn++;
           80 +                        }
           81 +                }
           82 +
           83                  x += w;
           84          }
           85          w = blw = TEXTW(m->ltsymbol);
           86 -- 
           87 2.25.4
           88