dwm-fancybar-6.2.diff - sites - public wiki contents of suckless.org | |
git clone git://git.suckless.org/sites | |
Log | |
Files | |
Refs | |
--- | |
dwm-fancybar-6.2.diff (2021B) | |
--- | |
1 diff --git a/dwm.c b/dwm.c | |
2 index 4465af1..eff2da6 100644 | |
3 --- a/dwm.c | |
4 +++ b/dwm.c | |
5 @@ -695,10 +695,10 @@ dirtomon(int dir) | |
6 void | |
7 drawbar(Monitor *m) | |
8 { | |
9 - int x, w, sw = 0; | |
10 + int x, w, sw = 0, tw, mw, ew = 0; | |
11 int boxs = drw->fonts->h / 9; | |
12 int boxw = drw->fonts->h / 6 + 2; | |
13 - unsigned int i, occ = 0, urg = 0; | |
14 + unsigned int i, occ = 0, urg = 0, n = 0; | |
15 Client *c; | |
16 | |
17 /* draw status first so it can be overdrawn by tags later */ | |
18 @@ -709,6 +709,8 @@ drawbar(Monitor *m) | |
19 } | |
20 | |
21 for (c = m->clients; c; c = c->next) { | |
22 + if (ISVISIBLE(c)) | |
23 + n++; | |
24 occ |= c->tags; | |
25 if (c->isurgent) | |
26 urg |= c->tags; | |
27 @@ -729,15 +731,39 @@ drawbar(Monitor *m) | |
28 x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0); | |
29 | |
30 if ((w = m->ww - sw - x) > bh) { | |
31 - if (m->sel) { | |
32 - drw_setscheme(drw, scheme[m == selmon ? SchemeS… | |
33 - drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->n… | |
34 - if (m->sel->isfloating) | |
35 - drw_rect(drw, x + boxs, boxs, boxw, box… | |
36 - } else { | |
37 - drw_setscheme(drw, scheme[SchemeNorm]); | |
38 - drw_rect(drw, x, 0, w, bh, 1, 1); | |
39 + if (n > 0) { | |
40 + tw = TEXTW(m->sel->name) + lrpad; | |
41 + mw = (tw >= w || n == 1) ? 0 : (w - tw) / (n - … | |
42 + | |
43 + i = 0; | |
44 + for (c = m->clients; c; c = c->next) { | |
45 + if (!ISVISIBLE(c) || c == m->sel) | |
46 + continue; | |
47 + tw = TEXTW(c->name); | |
48 + if(tw < mw) | |
49 + ew += (mw - tw); | |
50 + else | |
51 + i++; | |
52 + } | |
53 + if (i > 0) | |
54 + mw += ew / i; | |
55 + | |
56 + for (c = m->clients; c; c = c->next) { | |
57 + if (!ISVISIBLE(c)) | |
58 + continue; | |
59 + tw = MIN(m->sel == c ? w : mw, TEXTW(c-… | |
60 + | |
61 + drw_setscheme(drw, scheme[m->sel == c ?… | |
62 + if (tw > 0) /* trap special handling of… | |
63 + drw_text(drw, x, 0, tw, bh, lrp… | |
64 + if (c->isfloating) | |
65 + drw_rect(drw, x + boxs, boxs, b… | |
66 + x += tw; | |
67 + w -= tw; | |
68 + } | |
69 } | |
70 + drw_setscheme(drw, scheme[SchemeNorm]); | |
71 + drw_rect(drw, x, 0, w, bh, 1, 1); | |
72 } | |
73 drw_map(drw, m->barwin, 0, 0, m->ww, bh); | |
74 } |