Adding fancybar patch

This commit is contained in:
bakkeby
2019-09-06 23:47:06 +02:00
parent 611460c6a6
commit ec546d7995
3 changed files with 56 additions and 2 deletions

49
dwm.c
View File

@@ -825,6 +825,10 @@ void
drawbar(Monitor *m)
{
int x, w, sw = 0;
#if FANCYBAR_PATCH
int tw, mw, ew = 0;
unsigned int n = 0;
#endif // FANCYBAR_PATCH
#if SYSTRAY_PATCH
int stw = 0;
#endif // SYSTRAY_PATCH
@@ -850,6 +854,10 @@ drawbar(Monitor *m)
}
for (c = m->clients; c; c = c->next) {
#if FANCYBAR_PATCH
if (ISVISIBLE(c))
n++;
#endif // FANCYBAR_PATCH
occ |= c->tags;
if (c->isurgent)
urg |= c->tags;
@@ -870,10 +878,46 @@ drawbar(Monitor *m)
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
#if SYSTRAY_PATCH
if ((w = m->ww - sw - stw - x) > bh) {
if ((w = m->ww - sw - stw - x) > bh)
#else
if ((w = m->ww - sw - x) > bh) {
if ((w = m->ww - sw - x) > bh)
#endif // SYSTRAY_PATCH
{
#if FANCYBAR_PATCH
if (n > 0) {
tw = TEXTW(m->sel->name) + lrpad;
mw = (tw >= w || n == 1) ? 0 : (w - tw) / (n - 1);
i = 0;
for (c = m->clients; c; c = c->next) {
if (!ISVISIBLE(c) || c == m->sel)
continue;
tw = TEXTW(c->name);
if(tw < mw)
ew += (mw - tw);
else
i++;
}
if (i > 0)
mw += ew / i;
for (c = m->clients; c; c = c->next) {
if (!ISVISIBLE(c))
continue;
tw = MIN(m->sel == c ? w : mw, TEXTW(c->name));
drw_setscheme(drw, scheme[m->sel == c ? SchemeSel : SchemeNorm]);
if (tw > 0) /* trap special handling of 0 in drw_text */
drw_text(drw, x, 0, tw, bh, lrpad / 2, c->name, 0);
if (c->isfloating)
drw_rect(drw, x + boxs, boxs, boxw, boxw, c->isfixed, 0);
x += tw;
w -= tw;
}
}
drw_setscheme(drw, scheme[SchemeNorm]);
drw_rect(drw, x, 0, w, bh, 1, 1);
#else
if (m->sel) {
drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
@@ -883,6 +927,7 @@ drawbar(Monitor *m)
drw_setscheme(drw, scheme[SchemeNorm]);
drw_rect(drw, x, 0, w, bh, 1, 1);
}
#endif // FANCYBAR_PATCH
}
#if SYSTRAY_PATCH
drw_map(drw, m->barwin, 0, 0, m->ww - stw, bh);