2020-07-15 08:57:30 +02:00
|
|
|
int
|
2020-09-09 17:24:02 +02:00
|
|
|
width_awesomebar(Bar *bar, BarArg *a)
|
2020-07-15 08:57:30 +02:00
|
|
|
{
|
2020-09-09 17:24:02 +02:00
|
|
|
return a->w;
|
2020-07-15 08:57:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2020-09-09 17:24:02 +02:00
|
|
|
draw_awesomebar(Bar *bar, BarArg *a)
|
2020-07-15 08:57:30 +02:00
|
|
|
{
|
2020-08-22 16:25:56 +02:00
|
|
|
int n = 0, scm, remainder = 0, tabw, pad;
|
2020-07-18 13:03:30 +02:00
|
|
|
unsigned int i;
|
|
|
|
#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
|
|
|
Client *c;
|
2020-07-18 13:03:30 +02:00
|
|
|
for (c = bar->mon->clients; c; c = c->next)
|
2020-07-15 08:57:30 +02:00
|
|
|
if (ISVISIBLE(c))
|
|
|
|
n++;
|
|
|
|
|
|
|
|
if (n > 0) {
|
2020-07-18 13:03:30 +02:00
|
|
|
remainder = w % n;
|
|
|
|
tabw = w / n;
|
|
|
|
for (i = 0, c = bar->mon->clients; c; c = c->next, i++) {
|
2020-07-15 08:57:30 +02:00
|
|
|
if (!ISVISIBLE(c))
|
|
|
|
continue;
|
2020-07-18 13:03:30 +02:00
|
|
|
if (bar->mon->sel == c)
|
2020-07-15 08:57:30 +02:00
|
|
|
scm = SchemeTitleSel;
|
|
|
|
else if (HIDDEN(c))
|
|
|
|
scm = SchemeHid;
|
|
|
|
else
|
|
|
|
scm = SchemeTitleNorm;
|
|
|
|
|
2020-08-22 16:25:56 +02:00
|
|
|
pad = lrpad / 2;
|
|
|
|
#if BAR_CENTEREDWINDOWNAME_PATCH
|
2020-09-04 11:33:52 +02:00
|
|
|
if (TEXTW(c->name) < tabw)
|
2020-08-22 16:25:56 +02:00
|
|
|
pad = (tabw - TEXTW(c->name) + lrpad) / 2;
|
|
|
|
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
|
|
|
|
2020-07-15 08:57:30 +02:00
|
|
|
drw_setscheme(drw, scheme[scm]);
|
2020-09-09 17:24:02 +02:00
|
|
|
drw_text(drw, x, a->y, tabw + (i < remainder ? 1 : 0), a->h, pad, c->name, 0, False);
|
2020-09-16 11:07:23 +02:00
|
|
|
drawstateindicator(c->mon, c, 1, x, a->y, w, a->h, 0, 0, c->isfixed);
|
2020-08-13 15:42:49 +02:00
|
|
|
x += tabw + (i < remainder ? 1 : 0);
|
2020-07-15 08:57:30 +02:00
|
|
|
}
|
|
|
|
}
|
2020-08-22 08:43:07 +02:00
|
|
|
return n;
|
2020-07-15 08:57:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2020-09-09 17:24:02 +02:00
|
|
|
click_awesomebar(Bar *bar, Arg *arg, BarArg *a)
|
2020-07-15 08:57:30 +02:00
|
|
|
{
|
|
|
|
int x = 0, n = 0;
|
|
|
|
Client *c;
|
|
|
|
|
2020-07-18 13:03:30 +02:00
|
|
|
for (c = bar->mon->clients; c; c = c->next)
|
2020-07-15 08:57:30 +02:00
|
|
|
if (ISVISIBLE(c))
|
|
|
|
n++;
|
|
|
|
|
2020-07-18 13:03:30 +02:00
|
|
|
c = bar->mon->clients;
|
2020-07-15 08:57:30 +02:00
|
|
|
|
|
|
|
do {
|
|
|
|
if (!c || !ISVISIBLE(c))
|
|
|
|
continue;
|
|
|
|
else
|
2020-09-09 17:24:02 +02:00
|
|
|
x += (1.0 / (double)n) * a->w;
|
|
|
|
} while (c && a->x > x && (c = c->next));
|
2020-07-15 08:57:30 +02:00
|
|
|
|
|
|
|
if (c) {
|
|
|
|
arg->v = c;
|
|
|
|
return ClkWinTitle;
|
|
|
|
}
|
|
|
|
return -1;
|
2020-09-04 11:33:52 +02:00
|
|
|
}
|