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
|
|
|
{
|
2022-01-18 11:04:35 +01:00
|
|
|
int n = 0, scm, remainder = 0, tabw, tpad, tx, tw;
|
2020-07-18 13:03:30 +02:00
|
|
|
unsigned int i;
|
2022-01-18 11:04:35 +01:00
|
|
|
#if BAR_CENTEREDWINDOWNAME_PATCH
|
|
|
|
int cpad;
|
|
|
|
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
|
|
|
#if BAR_WINICON_PATCH
|
|
|
|
int ipad;
|
|
|
|
#endif // BAR_WINICON_PATCH
|
2020-10-18 14:26:57 +02:00
|
|
|
#if BAR_TITLE_LEFT_PAD_PATCH && BAR_TITLE_RIGHT_PAD_PATCH
|
2020-07-18 13:03:30 +02:00
|
|
|
int x = a->x + lrpad / 2, w = a->w - lrpad;
|
2020-10-18 14:26:57 +02:00
|
|
|
#elif BAR_TITLE_LEFT_PAD_PATCH
|
2020-07-18 13:03:30 +02:00
|
|
|
int x = a->x + lrpad / 2, w = a->w - lrpad / 2;
|
2020-10-18 14:26:57 +02:00
|
|
|
#elif BAR_TITLE_RIGHT_PAD_PATCH
|
2020-07-18 13:03:30 +02:00
|
|
|
int x = a->x, w = a->w - lrpad / 2;
|
|
|
|
#else
|
|
|
|
int x = a->x, w = a->w;
|
2020-10-18 14:26:57 +02:00
|
|
|
#endif // BAR_TITLE_LEFT_PAD_PATCH | BAR_TITLE_RIGHT_PAD_PATCH
|
2020-07-18 13:03:30 +02:00
|
|
|
|
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;
|
2021-05-21 10:16:49 +02:00
|
|
|
if (bar->mon->sel == c && HIDDEN(c))
|
|
|
|
scm = SchemeHidSel;
|
2020-07-15 08:57:30 +02:00
|
|
|
else if (HIDDEN(c))
|
2021-05-21 10:16:49 +02:00
|
|
|
scm = SchemeHidNorm;
|
|
|
|
else if (bar->mon->sel == c)
|
|
|
|
scm = SchemeTitleSel;
|
2020-07-15 08:57:30 +02:00
|
|
|
else
|
|
|
|
scm = SchemeTitleNorm;
|
|
|
|
|
2022-01-18 11:04:35 +01:00
|
|
|
tpad = lrpad / 2;
|
2020-08-22 16:25:56 +02:00
|
|
|
#if BAR_CENTEREDWINDOWNAME_PATCH
|
2022-01-18 11:04:35 +01:00
|
|
|
cpad = 0;
|
|
|
|
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
|
|
|
#if BAR_WINICON_PATCH
|
2022-03-06 11:38:22 +01:00
|
|
|
ipad = c->icon ? c->icw + ICONSPACING : 0;
|
2022-01-18 11:04:35 +01:00
|
|
|
#endif // BAR_WINICON_PATCH
|
|
|
|
|
|
|
|
tx = x;
|
|
|
|
tw = tabw;
|
|
|
|
|
|
|
|
#if BAR_WINICON_PATCH && BAR_CENTEREDWINDOWNAME_PATCH
|
|
|
|
if (TEXTW(c->name) + ipad < tabw)
|
|
|
|
cpad = (tabw - TEXTW(c->name) - ipad) / 2;
|
|
|
|
#elif BAR_CENTEREDWINDOWNAME_PATCH
|
2020-09-04 11:33:52 +02:00
|
|
|
if (TEXTW(c->name) < tabw)
|
2022-01-18 11:04:35 +01:00
|
|
|
cpad = (tabw - TEXTW(c->name)) / 2;
|
2020-08-22 16:25:56 +02:00
|
|
|
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
|
|
|
|
2020-07-15 08:57:30 +02:00
|
|
|
drw_setscheme(drw, scheme[scm]);
|
2021-07-27 13:40:53 +02:00
|
|
|
|
2022-01-18 11:04:35 +01:00
|
|
|
XSetForeground(drw->dpy, drw->gc, drw->scheme[ColBg].pixel);
|
|
|
|
XFillRectangle(drw->dpy, drw->drawable, drw->gc, tx, a->y, tw, a->h);
|
|
|
|
|
|
|
|
#if BAR_CENTEREDWINDOWNAME_PATCH
|
|
|
|
/* Apply center padding, if any */
|
|
|
|
tx += cpad;
|
|
|
|
tw -= cpad;
|
|
|
|
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
|
|
|
|
|
|
|
tx += tpad;
|
|
|
|
tw -= lrpad;
|
|
|
|
|
2021-07-27 13:40:53 +02:00
|
|
|
#if BAR_WINICON_PATCH
|
2022-01-18 11:04:35 +01:00
|
|
|
if (ipad) {
|
2022-03-06 11:38:22 +01:00
|
|
|
drw_pic(drw, tx, a->y + (a->h - c->ich) / 2, c->icw, c->ich, c->icon);
|
2022-01-18 11:04:35 +01:00
|
|
|
tx += ipad;
|
|
|
|
tw -= ipad;
|
|
|
|
}
|
2021-07-27 13:40:53 +02:00
|
|
|
#endif // BAR_WINICON_PATCH
|
|
|
|
|
2022-01-18 11:04:35 +01:00
|
|
|
drw_text(drw, tx, a->y, tw, a->h, 0, c->name, 0, False);
|
|
|
|
|
2020-11-05 13:47:13 +01:00
|
|
|
drawstateindicator(c->mon, c, 1, x, a->y, tabw + (i < remainder ? 1 : 0), 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
|
|
|
}
|
2021-06-14 07:16:17 +02:00
|
|
|
|