2022-12-03 15:25:31 +01:00
|
|
|
int
|
2022-12-03 17:54:18 +01:00
|
|
|
width_title(Bar *bar, BarWidthArg *a)
|
2022-12-03 15:25:31 +01:00
|
|
|
{
|
|
|
|
return a->max_width;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2022-12-03 17:54:18 +01:00
|
|
|
draw_title(Bar *bar, BarDrawArg *a)
|
2022-12-03 15:25:31 +01:00
|
|
|
{
|
2022-12-03 17:54:18 +01:00
|
|
|
int n = 0, scm, remainder = 0, tabw, padding;
|
|
|
|
unsigned int i;
|
2022-12-03 15:25:31 +01:00
|
|
|
int x = a->x, w = a->w;
|
2022-12-03 17:54:18 +01:00
|
|
|
|
|
|
|
Client *c;
|
|
|
|
for (c = bar->mon->clients; c; c = c->next)
|
|
|
|
if (ISVISIBLE(c))
|
|
|
|
n++;
|
|
|
|
|
|
|
|
if (n > 0) {
|
|
|
|
remainder = w % n;
|
|
|
|
tabw = w / n;
|
|
|
|
for (i = 0, c = bar->mon->clients; c; c = c->next, i++) {
|
|
|
|
if (!ISVISIBLE(c))
|
|
|
|
continue;
|
2022-12-04 12:45:51 +01:00
|
|
|
if (bar->mon->sel == c && colorselectedtitle)
|
2022-12-03 17:54:18 +01:00
|
|
|
scm = SchemeTitleSel;
|
2022-12-04 12:45:51 +01:00
|
|
|
else if (!colorselectedtitle)
|
|
|
|
scm = SchemeTitleNorm;
|
2022-12-03 17:54:18 +01:00
|
|
|
else if (HIDDEN(c))
|
|
|
|
scm = SchemeTitleHidden;
|
|
|
|
else
|
|
|
|
scm = SchemeTitleNorm;
|
|
|
|
|
|
|
|
padding = lrpad / 2;
|
|
|
|
if (TEXTW(c->name) < tabw && titleposition)
|
|
|
|
padding = (tabw - TEXTW(c->name) + lrpad) / 2;
|
|
|
|
|
|
|
|
drw_setscheme(drw, scheme[scm]);
|
2022-12-04 12:45:51 +01:00
|
|
|
#if USEWINICON
|
|
|
|
drw_text(drw, x, 0, tabw + (i < remainder ? 1 : 0), bh, padding + (c->name ? c->icw + iconspacing : 0), c->name, 0, False);
|
|
|
|
if (c->icon)
|
|
|
|
drw_pic(drw, x + padding, (bh - c->ich) / 2, c->icw, c->ich, c->icon);
|
|
|
|
#else
|
|
|
|
drw_text(drw, x, 0, tabw + padding (i < remainder ? 1 : 0), bh, padding, c->name, 0, False);
|
|
|
|
#endif
|
2022-12-03 17:54:18 +01:00
|
|
|
x += tabw + (i < remainder ? 1 : 0);
|
|
|
|
}
|
2022-12-03 15:25:31 +01:00
|
|
|
}
|
2022-12-03 17:54:18 +01:00
|
|
|
return a->x + a->w;
|
2022-12-03 15:25:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2022-12-03 17:54:18 +01:00
|
|
|
click_title(Bar *bar, Arg *arg, BarClickArg *a)
|
2022-12-03 15:25:31 +01:00
|
|
|
{
|
2022-12-03 17:54:18 +01:00
|
|
|
int x = 0, n = 0;
|
|
|
|
Client *c;
|
|
|
|
|
|
|
|
for (c = bar->mon->clients; c; c = c->next)
|
|
|
|
if (ISVISIBLE(c))
|
|
|
|
n++;
|
|
|
|
|
|
|
|
c = bar->mon->clients;
|
|
|
|
|
|
|
|
do {
|
|
|
|
if (!c || !ISVISIBLE(c))
|
|
|
|
continue;
|
|
|
|
else
|
|
|
|
x += (1.0 / (double)n) * a->rel_w;
|
|
|
|
} while (c && a->rel_x > x && (c = c->next));
|
|
|
|
|
|
|
|
if (c) {
|
|
|
|
arg->v = c;
|
|
|
|
return ClkWinTitle;
|
|
|
|
}
|
|
|
|
return -1;
|
2022-12-03 15:25:31 +01:00
|
|
|
}
|