2020-07-15 08:57:30 +02:00
|
|
|
int
|
2020-07-18 13:03:30 +02:00
|
|
|
width_fancybar(Bar *bar, BarWidthArg *a)
|
2020-07-15 08:57:30 +02:00
|
|
|
{
|
2020-07-15 14:10:47 +02:00
|
|
|
return a->max_width;
|
2020-07-15 08:57:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2020-07-18 13:03:30 +02:00
|
|
|
draw_fancybar(Bar *bar, BarDrawArg *a)
|
2020-07-15 08:57:30 +02:00
|
|
|
{
|
2020-07-18 13:03:30 +02:00
|
|
|
int ftw, mw, ew = 0, n = 0;
|
2020-07-15 08:57:30 +02:00
|
|
|
unsigned int i;
|
|
|
|
Client *c;
|
2020-07-18 13:03:30 +02:00
|
|
|
Monitor *m = bar->mon;
|
|
|
|
|
|
|
|
int boxs = drw->fonts->h / 9;
|
2020-07-15 08:57:30 +02:00
|
|
|
int boxw = drw->fonts->h / 6 + 2;
|
2020-07-18 13:03:30 +02:00
|
|
|
#if BAR_TITLE_LEFT_PAD && BAR_TITLE_RIGHT_PAD
|
|
|
|
int x = a->x + lrpad / 2, w = a->w - lrpad;
|
|
|
|
#elif BAR_TITLE_LEFT_PAD
|
|
|
|
int x = a->x + lrpad / 2, w = a->w - lrpad / 2;
|
|
|
|
#elif BAR_TITLE_RIGHT_PAD
|
|
|
|
int x = a->x, w = a->w - lrpad / 2;
|
|
|
|
#else
|
|
|
|
int x = a->x, w = a->w;
|
|
|
|
#endif // BAR_TITLE_LEFT_PAD | BAR_TITLE_RIGHT_PAD
|
2020-07-15 08:57:30 +02:00
|
|
|
|
|
|
|
for (c = m->clients; c; c = c->next) {
|
|
|
|
if (ISVISIBLE(c))
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n > 0) {
|
2020-07-18 13:03:30 +02:00
|
|
|
ftw = TEXTW(m->sel->name);
|
2020-07-15 08:57:30 +02:00
|
|
|
mw = (ftw >= w || n == 1) ? 0 : (w - ftw) / (n - 1);
|
|
|
|
|
|
|
|
i = 0;
|
2020-07-18 13:03:30 +02:00
|
|
|
|
2020-07-15 08:57:30 +02:00
|
|
|
for (c = m->clients; c; c = c->next) {
|
|
|
|
if (!ISVISIBLE(c) || c == m->sel)
|
|
|
|
continue;
|
|
|
|
ftw = TEXTW(c->name);
|
|
|
|
if (ftw < mw)
|
|
|
|
ew += (mw - ftw);
|
|
|
|
else
|
|
|
|
i++;
|
|
|
|
}
|
2020-07-18 13:03:30 +02:00
|
|
|
|
2020-07-15 08:57:30 +02:00
|
|
|
if (i > 0)
|
|
|
|
mw += ew / i;
|
|
|
|
|
|
|
|
for (c = m->clients; c; c = c->next) {
|
|
|
|
if (!ISVISIBLE(c))
|
|
|
|
continue;
|
|
|
|
ftw = MIN(m->sel == c ? w : mw, TEXTW(c->name));
|
|
|
|
|
|
|
|
#if BAR_VTCOLORS_PATCH
|
|
|
|
drw_setscheme(drw, scheme[m->sel == c ? SchemeTitleSel : SchemeTitleNorm]);
|
|
|
|
#elif BAR_TITLECOLOR_PATCH
|
|
|
|
drw_setscheme(drw, scheme[m->sel == c ? SchemeTitle : SchemeNorm]);
|
|
|
|
#else
|
|
|
|
drw_setscheme(drw, scheme[m->sel == c ? SchemeSel : SchemeNorm]);
|
|
|
|
#endif // BAR_VTCOLORS_PATCH / BAR_TITLECOLOR_PATCH
|
|
|
|
if (ftw > 0) /* trap special handling of 0 in drw_text */
|
|
|
|
#if BAR_PANGO_PATCH
|
|
|
|
drw_text(drw, x, 0, ftw, bh, lrpad / 2, c->name, 0, False);
|
|
|
|
#else
|
|
|
|
drw_text(drw, x, 0, ftw, bh, lrpad / 2, c->name, 0);
|
|
|
|
#endif // BAR_PANGO_PATCH
|
|
|
|
if (c->isfloating)
|
|
|
|
drw_rect(drw, x + boxs, boxs, boxw, boxw, c->isfixed, 0);
|
|
|
|
x += ftw;
|
|
|
|
w -= ftw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return x + w;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2020-07-18 13:03:30 +02:00
|
|
|
click_fancybar(Bar *bar, Arg *arg, BarClickArg *a)
|
2020-07-15 08:57:30 +02:00
|
|
|
{
|
|
|
|
return ClkWinTitle;
|
|
|
|
}
|
|
|
|
|
|
|
|
|