drw: cleanup drw_text, prevent gcc warning false-positive of unused var
... we don't allow passing text is NULL anymore either, for that behaviour just use drw_rect() (it is used in dwm).main
parent
e2e7fcb219
commit
44b242c763
35
drw.c
35
drw.c
|
@ -224,9 +224,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *tex
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
int tx, ty, th;
|
int tx, ty, th;
|
||||||
Extnts tex;
|
Extnts tex;
|
||||||
Colormap cmap;
|
XftDraw *d = NULL;
|
||||||
Visual *vis;
|
|
||||||
XftDraw *d;
|
|
||||||
Fnt *curfont, *nextfont;
|
Fnt *curfont, *nextfont;
|
||||||
size_t i, len;
|
size_t i, len;
|
||||||
int utf8strlen, utf8charlen, render;
|
int utf8strlen, utf8charlen, render;
|
||||||
|
@ -238,22 +236,18 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *tex
|
||||||
XftResult result;
|
XftResult result;
|
||||||
int charexists = 0;
|
int charexists = 0;
|
||||||
|
|
||||||
if (!(render = x || y || w || h))
|
if (!drw->scheme || !drw->fontcount)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!(render = x || y || w || h)) {
|
||||||
w = ~w;
|
w = ~w;
|
||||||
|
} else {
|
||||||
if (!drw || !drw->scheme) {
|
XSetForeground(drw->dpy, drw->gc, invert ?
|
||||||
return 0;
|
drw->scheme->fg->pix : drw->scheme->bg->pix);
|
||||||
} else if (render) {
|
|
||||||
XSetForeground(drw->dpy, drw->gc, invert ? drw->scheme->fg->pix : drw->scheme->bg->pix);
|
|
||||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
|
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
|
||||||
}
|
d = XftDrawCreate(drw->dpy, drw->drawable,
|
||||||
|
DefaultVisual(drw->dpy, drw->screen),
|
||||||
if (!text || !drw->fontcount) {
|
DefaultColormap(drw->dpy, drw->screen));
|
||||||
return 0;
|
|
||||||
} else if (render) {
|
|
||||||
cmap = DefaultColormap(drw->dpy, drw->screen);
|
|
||||||
vis = DefaultVisual(drw->dpy, drw->screen);
|
|
||||||
d = XftDrawCreate(drw->dpy, drw->drawable, vis, cmap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
curfont = drw->fonts[0];
|
curfont = drw->fonts[0];
|
||||||
|
@ -325,7 +319,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *tex
|
||||||
if (!drw->fonts[0]->pattern) {
|
if (!drw->fonts[0]->pattern) {
|
||||||
/* Refer to the comment in drw_font_xcreate for more
|
/* Refer to the comment in drw_font_xcreate for more
|
||||||
* information. */
|
* information. */
|
||||||
die("The first font in the cache must be loaded from a font string.\n");
|
die("the first font in the cache must be loaded from a font string.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
fcpattern = FcPatternDuplicate(drw->fonts[0]->pattern);
|
fcpattern = FcPatternDuplicate(drw->fonts[0]->pattern);
|
||||||
|
@ -344,14 +338,13 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *tex
|
||||||
if (curfont && XftCharExists(drw->dpy, curfont->xfont, utf8codepoint)) {
|
if (curfont && XftCharExists(drw->dpy, curfont->xfont, utf8codepoint)) {
|
||||||
drw->fonts[drw->fontcount++] = curfont;
|
drw->fonts[drw->fontcount++] = curfont;
|
||||||
} else {
|
} else {
|
||||||
if (curfont)
|
drw_font_free(curfont);
|
||||||
drw_font_free(curfont);
|
|
||||||
curfont = drw->fonts[0];
|
curfont = drw->fonts[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (render)
|
if (d)
|
||||||
XftDrawDestroy(d);
|
XftDrawDestroy(d);
|
||||||
|
|
||||||
return x;
|
return x;
|
||||||
|
|
Loading…
Reference in New Issue