2020-07-15 06:57:30 +00:00
|
|
|
int
|
2020-09-09 15:24:02 +00:00
|
|
|
width_fancybar(Bar *bar, BarArg *a)
|
2020-07-15 06:57:30 +00:00
|
|
|
{
|
2020-09-09 15:24:02 +00:00
|
|
|
return a->w;
|
2020-07-15 06:57:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2020-09-09 15:24:02 +00:00
|
|
|
draw_fancybar(Bar *bar, BarArg *a)
|
2020-07-15 06:57:30 +00:00
|
|
|
{
|
2020-07-18 11:03:30 +00:00
|
|
|
int ftw, mw, ew = 0, n = 0;
|
2020-07-15 06:57:30 +00:00
|
|
|
unsigned int i;
|
|
|
|
Client *c;
|
2020-07-18 11:03:30 +00:00
|
|
|
Monitor *m = bar->mon;
|
|
|
|
|
2020-10-18 12:26:57 +00:00
|
|
|
#if BAR_TITLE_LEFT_PAD_PATCH && BAR_TITLE_RIGHT_PAD_PATCH
|
2020-07-18 11:03:30 +00:00
|
|
|
int x = a->x + lrpad / 2, w = a->w - lrpad;
|
2020-10-18 12:26:57 +00:00
|
|
|
#elif BAR_TITLE_LEFT_PAD_PATCH
|
2020-07-18 11:03:30 +00:00
|
|
|
int x = a->x + lrpad / 2, w = a->w - lrpad / 2;
|
2020-10-18 12:26:57 +00:00
|
|
|
#elif BAR_TITLE_RIGHT_PAD_PATCH
|
2020-07-18 11:03:30 +00:00
|
|
|
int x = a->x, w = a->w - lrpad / 2;
|
|
|
|
#else
|
|
|
|
int x = a->x, w = a->w;
|
2020-10-18 12:26:57 +00:00
|
|
|
#endif // BAR_TITLE_LEFT_PAD_PATCH | BAR_TITLE_RIGHT_PAD_PATCH
|
2020-07-15 06:57:30 +00:00
|
|
|
|
|
|
|
for (c = m->clients; c; c = c->next) {
|
|
|
|
if (ISVISIBLE(c))
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n > 0) {
|
2020-07-18 11:03:30 +00:00
|
|
|
ftw = TEXTW(m->sel->name);
|
2020-07-15 06:57:30 +00:00
|
|
|
mw = (ftw >= w || n == 1) ? 0 : (w - ftw) / (n - 1);
|
|
|
|
|
|
|
|
i = 0;
|
2020-07-18 11:03:30 +00:00
|
|
|
|
2020-07-15 06:57:30 +00: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 11:03:30 +00:00
|
|
|
|
2020-07-15 06:57:30 +00: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));
|
|
|
|
drw_setscheme(drw, scheme[m->sel == c ? SchemeTitleSel : SchemeTitleNorm]);
|
|
|
|
if (ftw > 0) /* trap special handling of 0 in drw_text */
|
2020-09-09 15:24:02 +00:00
|
|
|
drw_text(drw, x, a->y, ftw, a->h, lrpad / 2, c->name, 0, False);
|
2020-11-05 12:47:13 +00:00
|
|
|
drawstateindicator(c->mon, c, 1, x, a->y, ftw, a->h, 0, 0, c->isfixed);
|
2020-07-15 06:57:30 +00:00
|
|
|
x += ftw;
|
|
|
|
w -= ftw;
|
|
|
|
}
|
|
|
|
}
|
2020-08-22 06:43:07 +00:00
|
|
|
return n;
|
2020-07-15 06:57:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2020-09-09 15:24:02 +00:00
|
|
|
click_fancybar(Bar *bar, Arg *arg, BarArg *a)
|
2020-07-15 06:57:30 +00:00
|
|
|
{
|
|
|
|
return ClkWinTitle;
|
|
|
|
}
|
|
|
|
|
|
|
|
|