Simplified Pango integration by settling on common function signatures.

This commit is contained in:
bakkeby
2020-08-22 20:31:17 +02:00
parent 46ebaea58f
commit 81f44b036c
13 changed files with 22 additions and 118 deletions

View File

@ -44,11 +44,7 @@ draw_awesomebar(Bar *bar, BarDrawArg *a)
#endif // BAR_CENTEREDWINDOWNAME_PATCH
drw_setscheme(drw, scheme[scm]);
#if BAR_PANGO_PATCH
drw_text(drw, x, 0, tabw + (i < remainder ? 1 : 0), bh, pad, c->name, 0, False);
#else
drw_text(drw, x, 0, tabw + (i < remainder ? 1 : 0), bh, pad, c->name, 0);
#endif // BAR_PANGO_PATCH
if (c->isfloating)
drawindicator(c->mon, c, 1, x, w, 0, 0, c->isfixed, floatindicatortype);
x += tabw + (i < remainder ? 1 : 0);

View File

@ -52,11 +52,7 @@ draw_fancybar(Bar *bar, BarDrawArg *a)
ftw = MIN(m->sel == c ? w : mw, TEXTW(c->name));
drw_setscheme(drw, scheme[m->sel == c ? SchemeTitleSel : SchemeTitleNorm]);
if (ftw > 0) /* trap special handling of 0 in drw_text */
#if BAR_PANGO_PATCH
drw_text(drw, x, 0, ftw, bh, lrpad / 2, c->name, 0, False);
#else
drw_text(drw, x, 0, ftw, bh, lrpad / 2, c->name, 0);
#endif // BAR_PANGO_PATCH
if (c->isfloating)
drawindicator(c->mon, c, 1, x, w, 0, 0, c->isfixed, floatindicatortype);
x += ftw;

View File

@ -188,7 +188,7 @@ flextitledraw(Monitor *m, Client *c, int unused, int x, int w, int tabscheme, Ar
pad = (w - TEXTW(c->name) + lrpad) / 2;
#endif // BAR_CENTEREDWINDOWNAME_PATCH
drw_text(drw, x, 0, w, bh, pad, c->name, 0);
drw_text(drw, x, 0, w, bh, pad, c->name, 0, False);
if (c->isfloating)
drawindicator(m, c, 1, x + 2, w, 0, 0, 0, floatindicatortype);

View File

@ -7,11 +7,7 @@ width_ltsymbol(Bar *bar, BarWidthArg *a)
int
draw_ltsymbol(Bar *bar, BarDrawArg *a)
{
#if BAR_PANGO_PATCH
return drw_text(drw, a->x, 0, a->w, bh, lrpad / 2, bar->mon->ltsymbol, 0, False);
#else
return drw_text(drw, a->x, 0, a->w, bh, lrpad / 2, bar->mon->ltsymbol, 0);
#endif // BAR_PANGO_PATCH
}
int

View File

@ -1,44 +1,28 @@
int
width_status(Bar *bar, BarWidthArg *a)
{
#if BAR_PANGO_PATCH
return TEXTWM(stext);
#else
return TEXTW(stext);
#endif // BAR_PANGO_PATCH
}
#if BAR_EXTRASTATUS_PATCH
int
width_status_es(Bar *bar, BarWidthArg *a)
{
#if BAR_PANGO_PATCH
return TEXTWM(estext) - lrpad;
#else
return TEXTW(estext) - lrpad;
#endif // BAR_PANGO_PATCH
}
#endif // BAR_EXTRASTATUS_PATCH
int
draw_status(Bar *bar, BarDrawArg *a)
{
#if BAR_PANGO_PATCH
return drw_text(drw, a->x, 0, a->w, bh, lrpad / 2, stext, 0, True);
#else
return drw_text(drw, a->x, 0, a->w, bh, lrpad / 2, stext, 0);
#endif // BAR_PANGO_PATCH
}
#if BAR_EXTRASTATUS_PATCH
int
draw_status_es(Bar *bar, BarDrawArg *a)
{
#if BAR_PANGO_PATCH
return drw_text(drw, a->x, 0, a->w, bh, 0, estext, 0, True);
#else
return drw_text(drw, a->x, 0, a->w, bh, 0, estext, 0);
#endif // BAR_PANGO_PATCH
}
#endif // BAR_EXTRASTATUS_PATCH

View File

@ -83,13 +83,8 @@ drawstatusbar(int x, char* stext)
isCode = 1;
text[i] = '\0';
#if BAR_PANGO_PATCH
w = TEXTWM(text) - lrpad;
drw_text(drw, x, 0, w, bh, 0, text, 0, True);
#else
w = TEXTW(text) - lrpad;
drw_text(drw, x, 0, w, bh, 0, text, 0);
#endif // BAR_PANGO_PATCH
x += w;
@ -156,13 +151,8 @@ drawstatusbar(int x, char* stext)
}
}
if (!isCode) {
#if BAR_PANGO_PATCH
w = TEXTWM(text) - lrpad;
drw_text(drw, x, 0, w, bh, 0, text, 0, True);
#else
w = TEXTW(text) - lrpad;
drw_text(drw, x, 0, w, bh, 0, text, 0);
#endif // BAR_PANGO_PATCH
x += w;
}
free(p);
@ -197,11 +187,7 @@ status2dtextlength(char* stext)
if (!isCode) {
isCode = 1;
text[i] = '\0';
#if BAR_PANGO_PATCH
w += TEXTWM(text) - lrpad;
#else
w += TEXTW(text) - lrpad;
#endif // BAR_PANGO_PATCH
text[i] = '^';
if (text[++i] == 'f')
w += atoi(text + ++i);
@ -213,11 +199,7 @@ status2dtextlength(char* stext)
}
}
if (!isCode)
#if BAR_PANGO_PATCH
w += TEXTWM(text) - lrpad;
#else
w += TEXTW(text) - lrpad;
#endif // BAR_PANGO_PATCH
free(p);
return w;
}

View File

@ -7,11 +7,7 @@ width_stbutton(Bar *bar, BarWidthArg *a)
int
draw_stbutton(Bar *bar, BarDrawArg *a)
{
#if BAR_PANGO_PATCH
return drw_text(drw, a->x, 0, a->w, bh, lrpad / 2, buttonbar, 0, False);
#else
return drw_text(drw, a->x, 0, a->w, bh, lrpad / 2, buttonbar, 0);
#endif // BAR_PANGO_PATCH
}
int

View File

@ -35,11 +35,9 @@ click_statuscmd_text(Arg *arg, int rel_x, char *text)
text[i] = '\0';
#if BAR_STATUS2D_PATCH && !BAR_BAR_STATUSCOLORS_PATCH
x += status2dtextlength(text);
#elif BAR_PANGO_PATCH
x += TEXTWM(text) - lrpad;
#else
x += TEXTW(text) - lrpad;
#endif // STATUS2D_PATCH
x += TEXTWM(text) - lrpad;
#endif // BAR_STATUS2D_PATCH
text[i] = ch;
text += i+1;
i = -1;

View File

@ -63,14 +63,10 @@ draw_tags(Bar *bar, BarDrawArg *a)
? SchemeUrg
: SchemeTagsNorm
]);
#if BAR_ALTERNATIVE_TAGS_PATCH && BAR_PANGO_PATCH
#if BAR_ALTERNATIVE_TAGS_PATCH
drw_text(drw, x, 0, w, bh, wdelta + lrpad / 2, (selmon->alttag ? tagsalt[i] : tags[i]), invert, False);
#elif BAR_ALTERNATIVE_TAGS_PATCH
drw_text(drw, x, 0, w, bh, wdelta + lrpad / 2, (selmon->alttag ? tagsalt[i] : tags[i]), invert);
#elif BAR_PANGO_PATCH
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], invert, False);
#else
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], invert);
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], invert, False);
#endif // BAR_ALTERNATIVE_TAGS_PATCH
drawindicator(m, NULL, occ, x, w, i, -1, invert, tagindicatortype);
x += w;

View File

@ -17,6 +17,7 @@ draw_wintitle(Bar *bar, BarDrawArg *a)
int x = a->x, w = a->w;
#endif // BAR_TITLE_LEFT_PAD_PATCH | BAR_TITLE_RIGHT_PAD_PATCH
Monitor *m = bar->mon;
int pad = lrpad / 2;
if (!m->sel) {
drw_setscheme(drw, scheme[SchemeTitleNorm]);
@ -29,19 +30,9 @@ draw_wintitle(Bar *bar, BarDrawArg *a)
XSetErrorHandler(xerrordummy);
#endif // BAR_IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH
#if BAR_CENTEREDWINDOWNAME_PATCH
int mid = (m->ww - TEXTW(m->sel->name)) / 2 - x;
#if BAR_PANGO_PATCH
drw_text(drw, x, 0, w, bh, mid, m->sel->name, 0, False);
#else
drw_text(drw, x, 0, w, bh, mid, m->sel->name, 0);
#endif // BAR_PANGO_PATCH
#else
#if BAR_PANGO_PATCH
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0, False);
#else
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
#endif // BAR_PANGO_PATCH
pad = (m->ww - TEXTW(m->sel->name)) / 2 - x;
#endif // BAR_CENTEREDWINDOWNAME_PATCH
drw_text(drw, x, 0, w, bh, pad, m->sel->name, 0, False);
#if BAR_IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH
XSync(dpy, False);
XSetErrorHandler(xerror);