mirror of
https://github.com/mintycube/dwm.git
synced 2024-10-22 14:05:45 +02:00
Refactoring window title drawing with regards to icons ref. #216
This commit is contained in:
parent
406faa9cc3
commit
489ac30092
@ -7,8 +7,14 @@ width_awesomebar(Bar *bar, BarArg *a)
|
|||||||
int
|
int
|
||||||
draw_awesomebar(Bar *bar, BarArg *a)
|
draw_awesomebar(Bar *bar, BarArg *a)
|
||||||
{
|
{
|
||||||
int n = 0, scm, remainder = 0, tabw, pad;
|
int n = 0, scm, remainder = 0, tabw, tpad, tx, tw;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
#if BAR_CENTEREDWINDOWNAME_PATCH
|
||||||
|
int cpad;
|
||||||
|
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
||||||
|
#if BAR_WINICON_PATCH
|
||||||
|
int ipad;
|
||||||
|
#endif // BAR_WINICON_PATCH
|
||||||
#if BAR_TITLE_LEFT_PAD_PATCH && BAR_TITLE_RIGHT_PAD_PATCH
|
#if BAR_TITLE_LEFT_PAD_PATCH && BAR_TITLE_RIGHT_PAD_PATCH
|
||||||
int x = a->x + lrpad / 2, w = a->w - lrpad;
|
int x = a->x + lrpad / 2, w = a->w - lrpad;
|
||||||
#elif BAR_TITLE_LEFT_PAD_PATCH
|
#elif BAR_TITLE_LEFT_PAD_PATCH
|
||||||
@ -39,22 +45,49 @@ draw_awesomebar(Bar *bar, BarArg *a)
|
|||||||
else
|
else
|
||||||
scm = SchemeTitleNorm;
|
scm = SchemeTitleNorm;
|
||||||
|
|
||||||
pad = lrpad / 2;
|
tpad = lrpad / 2;
|
||||||
#if BAR_CENTEREDWINDOWNAME_PATCH
|
#if BAR_CENTEREDWINDOWNAME_PATCH
|
||||||
|
cpad = 0;
|
||||||
|
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
||||||
|
#if BAR_WINICON_PATCH
|
||||||
|
ipad = c->icon ? c->icon->width + ICONSPACING : 0;
|
||||||
|
#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
|
||||||
if (TEXTW(c->name) < tabw)
|
if (TEXTW(c->name) < tabw)
|
||||||
pad = (tabw - TEXTW(c->name) + lrpad) / 2;
|
cpad = (tabw - TEXTW(c->name)) / 2;
|
||||||
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
||||||
|
|
||||||
drw_setscheme(drw, scheme[scm]);
|
drw_setscheme(drw, scheme[scm]);
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
#if BAR_WINICON_PATCH
|
#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 (ipad) {
|
||||||
if (c->icon)
|
drw_img(drw, tx, a->y + (a->h - c->icon->height) / 2, c->icon, tmpicon);
|
||||||
drw_img(drw, x + pad, a->y + (a->h - c->icon->height) / 2, c->icon, tmpicon);
|
tx += ipad;
|
||||||
#else
|
tw -= ipad;
|
||||||
drw_text(drw, x, a->y, tabw + (i < remainder ? 1 : 0), a->h, pad, c->name, 0, False);
|
}
|
||||||
#endif // BAR_WINICON_PATCH
|
#endif // BAR_WINICON_PATCH
|
||||||
|
|
||||||
|
drw_text(drw, tx, a->y, tw, a->h, 0, c->name, 0, False);
|
||||||
|
|
||||||
drawstateindicator(c->mon, c, 1, x, a->y, tabw + (i < remainder ? 1 : 0), a->h, 0, 0, c->isfixed);
|
drawstateindicator(c->mon, c, 1, x, a->y, tabw + (i < remainder ? 1 : 0), a->h, 0, 0, c->isfixed);
|
||||||
x += tabw + (i < remainder ? 1 : 0);
|
x += tabw + (i < remainder ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,10 @@ width_fancybar(Bar *bar, BarArg *a)
|
|||||||
int
|
int
|
||||||
draw_fancybar(Bar *bar, BarArg *a)
|
draw_fancybar(Bar *bar, BarArg *a)
|
||||||
{
|
{
|
||||||
int ftw, mw, ew = 0, n = 0;
|
int tabw, mw, ew = 0, n = 0, tx, tw;
|
||||||
|
#if BAR_WINICON_PATCH
|
||||||
|
int ipad;
|
||||||
|
#endif // BAR_WINICON_PATCH
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
Client *c;
|
Client *c;
|
||||||
Monitor *m = bar->mon;
|
Monitor *m = bar->mon;
|
||||||
@ -28,25 +31,25 @@ draw_fancybar(Bar *bar, BarArg *a)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
ftw = TEXTW(m->sel->name);
|
tabw = TEXTW(m->sel->name);
|
||||||
#if BAR_WINICON_PATCH
|
#if BAR_WINICON_PATCH
|
||||||
if (m->sel->icon)
|
if (m->sel->icon)
|
||||||
ftw += m->sel->icon->width + ICONSPACING;
|
tabw += m->sel->icon->width + ICONSPACING;
|
||||||
#endif // BAR_WINICON_PATCH
|
#endif // BAR_WINICON_PATCH
|
||||||
mw = (ftw >= w || n == 1) ? 0 : (w - ftw) / (n - 1);
|
mw = (tabw >= w || n == 1) ? 0 : (w - tabw) / (n - 1);
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
for (c = m->clients; c; c = c->next) {
|
for (c = m->clients; c; c = c->next) {
|
||||||
if (!ISVISIBLE(c) || c == m->sel)
|
if (!ISVISIBLE(c) || c == m->sel)
|
||||||
continue;
|
continue;
|
||||||
ftw = TEXTW(c->name);
|
tabw = TEXTW(c->name);
|
||||||
#if BAR_WINICON_PATCH
|
#if BAR_WINICON_PATCH
|
||||||
if (c->icon)
|
if (c->icon)
|
||||||
ftw += c->icon->width + ICONSPACING;
|
tabw += c->icon->width + ICONSPACING;
|
||||||
#endif // BAR_WINICON_PATCH
|
#endif // BAR_WINICON_PATCH
|
||||||
if (ftw < mw)
|
if (tabw < mw)
|
||||||
ew += (mw - ftw);
|
ew += (mw - tabw);
|
||||||
else
|
else
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@ -57,24 +60,36 @@ draw_fancybar(Bar *bar, BarArg *a)
|
|||||||
for (c = m->clients; c; c = c->next) {
|
for (c = m->clients; c; c = c->next) {
|
||||||
if (!ISVISIBLE(c))
|
if (!ISVISIBLE(c))
|
||||||
continue;
|
continue;
|
||||||
ftw = MIN(m->sel == c ? w : mw, TEXTW(c->name));
|
tabw = MIN(m->sel == c ? w : mw, TEXTW(c->name));
|
||||||
|
#if BAR_WINICON_PATCH
|
||||||
|
ipad = c->icon ? c->icon->width + ICONSPACING : 0;
|
||||||
|
tabw += ipad;
|
||||||
|
#endif // BAR_WINICON_PATCH
|
||||||
|
tx = x;
|
||||||
|
tw = tabw;
|
||||||
drw_setscheme(drw, scheme[m->sel == c ? SchemeTitleSel : SchemeTitleNorm]);
|
drw_setscheme(drw, scheme[m->sel == c ? SchemeTitleSel : SchemeTitleNorm]);
|
||||||
if (ftw > 0) { /* trap special handling of 0 in drw_text */
|
|
||||||
|
|
||||||
drw_text(drw, x, a->y, ftw, a->h, lrpad / 2, c->name, 0, False);
|
XSetForeground(drw->dpy, drw->gc, drw->scheme[ColBg].pixel);
|
||||||
|
XFillRectangle(drw->dpy, drw->drawable, drw->gc, tx, a->y, tw, a->h);
|
||||||
|
|
||||||
|
if (tabw <= 0) /* trap special handling of 0 in drw_text */
|
||||||
|
continue;
|
||||||
|
|
||||||
|
tx += lrpad / 2;
|
||||||
|
tw -= lrpad;
|
||||||
|
|
||||||
#if BAR_WINICON_PATCH
|
#if BAR_WINICON_PATCH
|
||||||
drw_text(drw, x, a->y, ftw, a->h, lrpad / 2 + (c->icon ? c->icon->width + ICONSPACING : 0), c->name, 0, False);
|
if (ipad) {
|
||||||
if (c->icon)
|
drw_img(drw, tx, a->y + (a->h - c->icon->height) / 2, c->icon, tmpicon);
|
||||||
drw_img(drw, x + lrpad / 2, a->y + (a->h - c->icon->height) / 2, c->icon, tmpicon);
|
tx += ipad;
|
||||||
#else
|
tw -= ipad;
|
||||||
drw_text(drw, x, a->y, ftw, a->h, lrpad / 2, c->name, 0, False);
|
}
|
||||||
#endif // BAR_WINICON_PATCH
|
#endif // BAR_WINICON_PATCH
|
||||||
|
|
||||||
}
|
drw_text(drw, tx, a->y, tw, a->h, 0, c->name, 0, False);
|
||||||
drawstateindicator(c->mon, c, 1, x, a->y, ftw, a->h, 0, 0, c->isfixed);
|
drawstateindicator(c->mon, c, 1, x, a->y, tabw, a->h, 0, 0, c->isfixed);
|
||||||
x += ftw;
|
x += tabw;
|
||||||
w -= ftw;
|
w -= tabw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return n;
|
return n;
|
||||||
|
@ -166,11 +166,21 @@ getselschemefor(int scheme)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
flextitledraw(Monitor *m, Client *c, int unused, int x, int w, int tabscheme, Arg *arg, BarArg *barg)
|
flextitledraw(Monitor *m, Client *c, int unused, int x, int w, int tabscheme, Arg *arg, BarArg *a)
|
||||||
{
|
{
|
||||||
if (!c)
|
if (!c)
|
||||||
return;
|
return;
|
||||||
int i, nclienttags = 0, nviewtags = 0, pad = lrpad / 2;
|
int i, nclienttags = 0, nviewtags = 0;
|
||||||
|
int tpad = lrpad / 2;
|
||||||
|
#if BAR_WINICON_PATCH
|
||||||
|
int ipad = c->icon ? c->icon->width + ICONSPACING : 0;
|
||||||
|
#endif // BAR_WINICON_PATCH
|
||||||
|
#if BAR_CENTEREDWINDOWNAME_PATCH
|
||||||
|
int cpad = 0;
|
||||||
|
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
||||||
|
int tx = x;
|
||||||
|
int tw = w;
|
||||||
|
|
||||||
int clientscheme = (
|
int clientscheme = (
|
||||||
c == selmon->sel && HIDDEN(c)
|
c == selmon->sel && HIDDEN(c)
|
||||||
? SchemeHidSel
|
? SchemeHidSel
|
||||||
@ -182,30 +192,49 @@ flextitledraw(Monitor *m, Client *c, int unused, int x, int w, int tabscheme, Ar
|
|||||||
? SchemeUrg
|
? SchemeUrg
|
||||||
: tabscheme
|
: tabscheme
|
||||||
);
|
);
|
||||||
|
|
||||||
drw_setscheme(drw, scheme[clientscheme]);
|
drw_setscheme(drw, scheme[clientscheme]);
|
||||||
XSetWindowBorder(dpy, c->win, scheme[clientscheme][ColBorder].pixel);
|
XSetWindowBorder(dpy, c->win, scheme[clientscheme][ColBorder].pixel);
|
||||||
if (w <= TEXTW("A") - lrpad + pad) // reduce text padding if wintitle is too small
|
|
||||||
pad = (w - TEXTW("A") + lrpad < 0 ? 0 : (w - TEXTW("A") + lrpad) / 2);
|
if (w <= TEXTW("A") - lrpad + tpad) // reduce text padding if wintitle is too small
|
||||||
#if BAR_CENTEREDWINDOWNAME_PATCH
|
tpad = (w - TEXTW("A") + lrpad < 0 ? 0 : (w - TEXTW("A") + lrpad) / 2);
|
||||||
|
#if BAR_WINICON_PATCH && BAR_CENTEREDWINDOWNAME_PATCH
|
||||||
|
else if (TEXTW(c->name) + ipad < w)
|
||||||
|
cpad = (w - TEXTW(c->name) - ipad) / 2;
|
||||||
|
#elif BAR_CENTEREDWINDOWNAME_PATCH
|
||||||
else if (TEXTW(c->name) < w)
|
else if (TEXTW(c->name) < w)
|
||||||
pad = (w - TEXTW(c->name) + lrpad) / 2;
|
cpad = (w - TEXTW(c->name)) / 2;
|
||||||
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
||||||
|
|
||||||
|
XSetForeground(drw->dpy, drw->gc, drw->scheme[ColBg].pixel);
|
||||||
|
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, a->y, w, a->h);
|
||||||
|
|
||||||
|
#if BAR_CENTEREDWINDOWNAME_PATCH
|
||||||
|
/* Apply center padding, if any */
|
||||||
|
tx += cpad;
|
||||||
|
tw -= cpad;
|
||||||
|
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
||||||
|
|
||||||
|
tx += tpad;
|
||||||
|
tw -= lrpad;
|
||||||
|
|
||||||
#if BAR_WINICON_PATCH
|
#if BAR_WINICON_PATCH
|
||||||
drw_text(drw, x, barg->y, w, barg->h, pad + (c->icon ? c->icon->width + ICONSPACING : 0), c->name, 0, False);
|
if (ipad) {
|
||||||
if (c->icon)
|
drw_img(drw, tx, a->y + (a->h - c->icon->height) / 2, c->icon, tmpicon);
|
||||||
drw_img(drw, x + pad, barg->y + (barg->h - c->icon->height) / 2, c->icon, tmpicon);
|
tx += ipad;
|
||||||
#else
|
tw -= ipad;
|
||||||
drw_text(drw, x, barg->y, w, barg->h, pad, c->name, 0, False);
|
}
|
||||||
#endif // BAR_WINICON_PATCH
|
#endif // BAR_WINICON_PATCH
|
||||||
|
|
||||||
drawstateindicator(m, c, 1, x + 2, barg->y, w, barg->h, 0, 0, 0);
|
drw_text(drw, tx, a->y, tw, a->h, 0, c->name, 0, False);
|
||||||
|
drawstateindicator(m, c, 1, x + 2, a->y, w, a->h, 0, 0, 0);
|
||||||
|
|
||||||
if (FLEXWINTITLE_BORDERS) {
|
if (FLEXWINTITLE_BORDERS) {
|
||||||
XSetForeground(drw->dpy, drw->gc, scheme[SchemeSel][ColBorder].pixel);
|
XSetForeground(drw->dpy, drw->gc, scheme[SchemeSel][ColBorder].pixel);
|
||||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, barg->y, 1, barg->h);
|
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, a->y, 1, a->h);
|
||||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x + w - (x + w >= barg->w ? 1 : 0), barg->y, 1, barg->h);
|
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x + w - (x + w >= a->w ? 1 : 0), a->y, 1, a->h);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Optional tags icons */
|
/* Optional tags icons */
|
||||||
for (i = 0; i < NUMTAGS; i++) {
|
for (i = 0; i < NUMTAGS; i++) {
|
||||||
if ((m->tagset[m->seltags] >> i) & 1)
|
if ((m->tagset[m->seltags] >> i) & 1)
|
||||||
@ -215,7 +244,7 @@ flextitledraw(Monitor *m, Client *c, int unused, int x, int w, int tabscheme, Ar
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (TAGSINDICATOR == 2 || nclienttags > 1 || nviewtags > 1)
|
if (TAGSINDICATOR == 2 || nclienttags > 1 || nviewtags > 1)
|
||||||
drawindicator(m, c, 1, x, barg->y, w, barg->h, 0, 0, 0, INDICATOR_RIGHT_TAGS);
|
drawindicator(m, c, 1, x, a->y, w, a->h, 0, 0, 0, INDICATOR_RIGHT_TAGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef HIDDEN
|
#ifndef HIDDEN
|
||||||
|
@ -36,11 +36,21 @@ click_bartabgroups(Bar *bar, Arg *arg, BarArg *a)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
bartabdraw(Monitor *m, Client *c, int unused, int x, int w, int groupactive, Arg *arg, BarArg *barg)
|
bartabdraw(Monitor *m, Client *c, int unused, int x, int w, int groupactive, Arg *arg, BarArg *a)
|
||||||
{
|
{
|
||||||
if (!c)
|
if (!c)
|
||||||
return;
|
return;
|
||||||
int i, nclienttags = 0, nviewtags = 0, pad = lrpad / 2;
|
int i, nclienttags = 0, nviewtags = 0;
|
||||||
|
int tpad = lrpad / 2;
|
||||||
|
#if BAR_WINICON_PATCH
|
||||||
|
int ipad = c->icon ? c->icon->width + ICONSPACING : 0;
|
||||||
|
#endif // BAR_WINICON_PATCH
|
||||||
|
#if BAR_CENTEREDWINDOWNAME_PATCH
|
||||||
|
int cpad = 0;
|
||||||
|
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
||||||
|
int tx = x;
|
||||||
|
int tw = w;
|
||||||
|
|
||||||
drw_setscheme(drw, scheme[
|
drw_setscheme(drw, scheme[
|
||||||
m->sel == c
|
m->sel == c
|
||||||
#ifdef HIDDEN
|
#ifdef HIDDEN
|
||||||
@ -55,27 +65,44 @@ bartabdraw(Monitor *m, Client *c, int unused, int x, int w, int groupactive, Arg
|
|||||||
? SchemeTitleSel
|
? SchemeTitleSel
|
||||||
: SchemeTitleNorm
|
: SchemeTitleNorm
|
||||||
]);
|
]);
|
||||||
if (w <= TEXTW("A") - lrpad + pad) // reduce text padding if wintitle is too small
|
if (w <= TEXTW("A") - lrpad + tpad) // reduce text padding if wintitle is too small
|
||||||
pad = (w - TEXTW("A") + lrpad < 0 ? 0 : (w - TEXTW("A") + lrpad) / 2);
|
tpad = (w - TEXTW("A") + lrpad < 0 ? 0 : (w - TEXTW("A") + lrpad) / 2);
|
||||||
#if BAR_CENTEREDWINDOWNAME_PATCH
|
#if BAR_WINICON_PATCH && BAR_CENTEREDWINDOWNAME_PATCH
|
||||||
|
else if (TEXTW(c->name) + ipad < w)
|
||||||
|
cpad = (w - TEXTW(c->name) - ipad) / 2;
|
||||||
|
#elif BAR_CENTEREDWINDOWNAME_PATCH
|
||||||
else if (TEXTW(c->name) < w)
|
else if (TEXTW(c->name) < w)
|
||||||
pad = (w - TEXTW(c->name) + lrpad) / 2;
|
cpad = (w - TEXTW(c->name)) / 2;
|
||||||
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
||||||
|
|
||||||
|
XSetForeground(drw->dpy, drw->gc, drw->scheme[ColBg].pixel);
|
||||||
|
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, a->y, w, a->h);
|
||||||
|
|
||||||
|
#if BAR_CENTEREDWINDOWNAME_PATCH
|
||||||
|
/* Apply center padding, if any */
|
||||||
|
tx += cpad;
|
||||||
|
tw -= cpad;
|
||||||
|
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
||||||
|
|
||||||
|
tx += tpad;
|
||||||
|
tw -= lrpad;
|
||||||
|
|
||||||
#if BAR_WINICON_PATCH
|
#if BAR_WINICON_PATCH
|
||||||
drw_text(drw, x, barg->y, w, barg->h, pad + (c->icon ? c->icon->width + ICONSPACING : 0), c->name, 0, False);
|
if (ipad) {
|
||||||
if (c->icon)
|
drw_img(drw, tx, a->y + (a->h - c->icon->height) / 2, c->icon, tmpicon);
|
||||||
drw_img(drw, x + pad, barg->y + (barg->h - c->icon->height) / 2, c->icon, tmpicon);
|
tx += ipad;
|
||||||
#else
|
tw -= ipad;
|
||||||
drw_text(drw, x, barg->y, w, barg->h, pad, c->name, 0, False);
|
}
|
||||||
#endif // BAR_WINICON_PATCH
|
#endif // BAR_WINICON_PATCH
|
||||||
|
|
||||||
drawstateindicator(m, c, 1, x, barg->y, w, barg->h, 0, 0, c->isfixed);
|
drw_text(drw, tx, a->y, tw, a->h, 0, c->name, 0, False);
|
||||||
|
|
||||||
|
drawstateindicator(m, c, 1, x, a->y, w, a->h, 0, 0, c->isfixed);
|
||||||
|
|
||||||
if (BARTAB_BORDERS) {
|
if (BARTAB_BORDERS) {
|
||||||
XSetForeground(drw->dpy, drw->gc, scheme[SchemeSel][ColBorder].pixel);
|
XSetForeground(drw->dpy, drw->gc, scheme[SchemeSel][ColBorder].pixel);
|
||||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, barg->y, 1, barg->h);
|
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, a->y, 1, a->h);
|
||||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x + w - (x + w >= barg->w ? 1 : 0), barg->y, 1, barg->h);
|
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x + w - (x + w >= a->w ? 1 : 0), a->y, 1, a->h);
|
||||||
}
|
}
|
||||||
/* Optional tags icons */
|
/* Optional tags icons */
|
||||||
for (i = 0; i < NUMTAGS; i++) {
|
for (i = 0; i < NUMTAGS; i++) {
|
||||||
@ -86,7 +113,7 @@ bartabdraw(Monitor *m, Client *c, int unused, int x, int w, int groupactive, Arg
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (TAGSINDICATOR == 2 || nclienttags > 1 || nviewtags > 1)
|
if (TAGSINDICATOR == 2 || nclienttags > 1 || nviewtags > 1)
|
||||||
drawindicator(m, c, 1, x, barg->y, w, barg->h, 0, 0, 0, INDICATOR_RIGHT_TAGS);
|
drawindicator(m, c, 1, x, a->y, w, a->h, 0, 0, 0, INDICATOR_RIGHT_TAGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef HIDDEN
|
#ifndef HIDDEN
|
||||||
|
@ -18,7 +18,6 @@ draw_wintitle(Bar *bar, BarArg *a)
|
|||||||
#endif // BAR_TITLE_LEFT_PAD_PATCH | BAR_TITLE_RIGHT_PAD_PATCH
|
#endif // BAR_TITLE_LEFT_PAD_PATCH | BAR_TITLE_RIGHT_PAD_PATCH
|
||||||
Monitor *m = bar->mon;
|
Monitor *m = bar->mon;
|
||||||
Client *c = m->sel;
|
Client *c = m->sel;
|
||||||
int pad = lrpad / 2;
|
|
||||||
|
|
||||||
if (!c) {
|
if (!c) {
|
||||||
drw_setscheme(drw, scheme[SchemeTitleNorm]);
|
drw_setscheme(drw, scheme[SchemeTitleNorm]);
|
||||||
@ -26,23 +25,53 @@ draw_wintitle(Bar *bar, BarArg *a)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int tpad = lrpad / 2;
|
||||||
|
#if BAR_WINICON_PATCH
|
||||||
|
int ipad = c->icon ? c->icon->width + ICONSPACING : 0;
|
||||||
|
#endif // BAR_WINICON_PATCH
|
||||||
|
#if BAR_CENTEREDWINDOWNAME_PATCH
|
||||||
|
int cpad = 0;
|
||||||
|
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
||||||
|
int tx = x;
|
||||||
|
int tw = w;
|
||||||
|
|
||||||
drw_setscheme(drw, scheme[m == selmon ? SchemeTitleSel : SchemeTitleNorm]);
|
drw_setscheme(drw, scheme[m == selmon ? SchemeTitleSel : SchemeTitleNorm]);
|
||||||
#if BAR_IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH
|
#if BAR_IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH
|
||||||
XSetErrorHandler(xerrordummy);
|
XSetErrorHandler(xerrordummy);
|
||||||
#endif // BAR_IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH
|
#endif // BAR_IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH
|
||||||
#if BAR_CENTEREDWINDOWNAME_PATCH
|
|
||||||
if (TEXTW(c->name) < w)
|
if (w <= TEXTW("A") - lrpad + tpad) // reduce text padding if wintitle is too small
|
||||||
pad = (w - TEXTW(c->name) + lrpad) / 2;
|
tpad = (w - TEXTW("A") + lrpad < 0 ? 0 : (w - TEXTW("A") + lrpad) / 2);
|
||||||
|
#if BAR_WINICON_PATCH && BAR_CENTEREDWINDOWNAME_PATCH
|
||||||
|
else if (TEXTW(c->name) + ipad < w)
|
||||||
|
cpad = (w - TEXTW(c->name) - ipad) / 2;
|
||||||
|
#elif BAR_CENTEREDWINDOWNAME_PATCH
|
||||||
|
else if (TEXTW(c->name) < w)
|
||||||
|
cpad = (w - TEXTW(c->name)) / 2;
|
||||||
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
||||||
|
|
||||||
|
XSetForeground(drw->dpy, drw->gc, drw->scheme[ColBg].pixel);
|
||||||
|
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, a->y, w, a->h);
|
||||||
|
|
||||||
|
#if BAR_CENTEREDWINDOWNAME_PATCH
|
||||||
|
/* Apply center padding, if any */
|
||||||
|
tx += cpad;
|
||||||
|
tw -= cpad;
|
||||||
|
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
||||||
|
|
||||||
|
tx += tpad;
|
||||||
|
tw -= lrpad;
|
||||||
|
|
||||||
#if BAR_WINICON_PATCH
|
#if BAR_WINICON_PATCH
|
||||||
drw_text(drw, x, a->y, w, a->h, pad + (c->icon ? c->icon->width + ICONSPACING : 0), c->name, 0, False);
|
if (ipad) {
|
||||||
if (c->icon)
|
drw_img(drw, tx, a->y + (a->h - c->icon->height) / 2, c->icon, tmpicon);
|
||||||
drw_img(drw, x + pad, a->y + (a->h - c->icon->height) / 2, c->icon, tmpicon);
|
tx += ipad;
|
||||||
#else
|
tw -= ipad;
|
||||||
drw_text(drw, x, a->y, w, a->h, pad, c->name, 0, False);
|
}
|
||||||
#endif // BAR_WINICON_PATCH
|
#endif // BAR_WINICON_PATCH
|
||||||
|
|
||||||
|
drw_text(drw, tx, a->y, tw, a->h, 0, c->name, 0, False);
|
||||||
|
|
||||||
#if BAR_IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH
|
#if BAR_IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
XSetErrorHandler(xerror);
|
XSetErrorHandler(xerror);
|
||||||
|
Loading…
Reference in New Issue
Block a user