applied fancybar patch

master
Alessandro Mauri 4 years ago
parent 53e5cb1e4a
commit 3640c4a2b2
  1. 47
      dwm.c

47
dwm.c

@ -697,20 +697,22 @@ dirtomon(int dir)
void void
drawbar(Monitor *m) drawbar(Monitor *m)
{ {
int x, w, sw = 0; int x, w, tw = 0, mw, ew = 0;
int boxs = drw->fonts->h / 9; int boxs = drw->fonts->h / 9;
int boxw = drw->fonts->h / 6 + 2; int boxw = drw->fonts->h / 6 + 2;
unsigned int i, occ = 0, urg = 0; unsigned int i, occ = 0, urg = 0, n = 0;
Client *c; Client *c;
/* draw status first so it can be overdrawn by tags later */ /* draw status first so it can be overdrawn by tags later */
if (m == selmon) { /* status is only drawn on selected monitor */ if (m == selmon) { /* status is only drawn on selected monitor */
drw_setscheme(drw, scheme[SchemeStatus]); drw_setscheme(drw, scheme[SchemeStatus]);
sw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
drw_text(drw, m->ww - sw, 0, sw, bh, 0, stext, 0); drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
} }
for (c = m->clients; c; c = c->next) { for (c = m->clients; c; c = c->next) {
if (ISVISIBLE(c))
n++;
occ |= c->tags; occ |= c->tags;
if (c->isurgent) if (c->isurgent)
urg |= c->tags; urg |= c->tags;
@ -730,7 +732,41 @@ drawbar(Monitor *m)
drw_setscheme(drw, scheme[SchemeTagsNorm]); drw_setscheme(drw, scheme[SchemeTagsNorm]);
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0); x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
if ((w = m->ww - sw - x) > bh) { if ((w = m->ww - tw - x) > bh) {
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 ? SchemeInfoSel : SchemeInfoNorm]);
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[SchemeInfoNorm]);
drw_rect(drw, x, 0, w, bh, 1, 1);
/*
if (m->sel) { if (m->sel) {
drw_setscheme(drw, scheme[m == selmon ? SchemeInfoSel : SchemeInfoNorm]); drw_setscheme(drw, scheme[m == selmon ? SchemeInfoSel : SchemeInfoNorm]);
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0); drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
@ -740,6 +776,7 @@ drawbar(Monitor *m)
drw_setscheme(drw, scheme[SchemeInfoNorm]); drw_setscheme(drw, scheme[SchemeInfoNorm]);
drw_rect(drw, x, 0, w, bh, 1, 1); drw_rect(drw, x, 0, w, bh, 1, 1);
} }
*/
} }
drw_map(drw, m->barwin, 0, 0, m->ww, bh); drw_map(drw, m->barwin, 0, 0, m->ww, bh);
} }

Loading…
Cancel
Save