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