Introduction
Introduction Statistics Contact Development Disclaimer Help
drw: cleanup drw_text, prevent gcc warning false-positive of unused var - dmenu…
git clone git://git.suckless.org/dmenu
Log
Files
Refs
README
LICENSE
---
commit 44b242c76359e21b97418675f253d45feb7c04e0
parent e2e7fcb2198d40e2a50591932ee2b2a8f9969a5f
Author: Hiltjo Posthuma <[email protected]>
Date: Tue, 20 Oct 2015 22:56:57 +0200
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).
Diffstat:
M drw.c | 35 +++++++++++++----------------…
1 file changed, 14 insertions(+), 21 deletions(-)
---
diff --git a/drw.c b/drw.c
@@ -224,9 +224,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned i…
char buf[1024];
int tx, ty, th;
Extnts tex;
- Colormap cmap;
- Visual *vis;
- XftDraw *d;
+ XftDraw *d = NULL;
Fnt *curfont, *nextfont;
size_t i, len;
int utf8strlen, utf8charlen, render;
@@ -238,22 +236,18 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned…
XftResult result;
int charexists = 0;
- if (!(render = x || y || w || h))
- w = ~w;
-
- if (!drw || !drw->scheme) {
+ if (!drw->scheme || !drw->fontcount)
return 0;
- } else if (render) {
- XSetForeground(drw->dpy, drw->gc, invert ? drw->scheme->fg->pi…
- XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
- }
- if (!text || !drw->fontcount) {
- 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);
+ if (!(render = x || y || w || h)) {
+ w = ~w;
+ } else {
+ 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);
+ d = XftDrawCreate(drw->dpy, drw->drawable,
+ DefaultVisual(drw->dpy, drw->screen),
+ DefaultColormap(drw->dpy, drw->screen));
}
curfont = drw->fonts[0];
@@ -325,7 +319,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned i…
if (!drw->fonts[0]->pattern) {
/* Refer to the comment in drw_font_xcreate fo…
* information. */
- die("The first font in the cache must be loade…
+ die("the first font in the cache must be loade…
}
fcpattern = FcPatternDuplicate(drw->fonts[0]->pattern);
@@ -344,14 +338,13 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned…
if (curfont && XftCharExists(drw->dpy, curfont…
drw->fonts[drw->fontcount++] = curfont;
} else {
- if (curfont)
- drw_font_free(curfont);
+ drw_font_free(curfont);
curfont = drw->fonts[0];
}
}
}
}
- if (render)
+ if (d)
XftDrawDestroy(d);
return x;
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.