X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=draw.c;h=dafc10794835689d6a0e33b7b34e1d9551efa717;hb=3b590beda2fb23400f74394badd7a5231d4d7920;hp=d0f21cdae573274041241f8f06b84eda8a62384a;hpb=13ef97e65ea5a713a3d5ab46916d1ac6d071b825;p=dmenu.git diff --git a/draw.c b/draw.c index d0f21cd..dafc107 100644 --- a/draw.c +++ b/draw.c @@ -10,8 +10,7 @@ /* static */ static unsigned int -textnw(const char *text, unsigned int len) -{ +textnw(const char *text, unsigned int len) { XRectangle r; if(dc.font.set) { @@ -24,8 +23,7 @@ textnw(const char *text, unsigned int len) /* extern */ void -drawtext(const char *text, unsigned long col[ColLast]) -{ +drawtext(const char *text, unsigned long col[ColLast]) { int x, y, w, h; static char buf[256]; unsigned int len, olen; @@ -78,18 +76,17 @@ drawtext(const char *text, unsigned long col[ColLast]) } unsigned long -getcolor(const char *colstr) -{ +getcolor(const char *colstr, const char *alternate) { Colormap cmap = DefaultColormap(dpy, screen); XColor color; - XAllocNamedColor(dpy, cmap, colstr, &color, &color); + if(XAllocNamedColor(dpy, cmap, colstr, &color, &color) != Success) + XAllocNamedColor(dpy, cmap, alternate, &color, &color); return color.pixel; } void -setfont(const char *fontstr) -{ +setfont(const char *fontstr) { char **missing, *def; int i, n; @@ -137,7 +134,6 @@ setfont(const char *fontstr) } unsigned int -textw(const char *text) -{ +textw(const char *text) { return textnw(text, strlen(text)) + dc.font.height; }