added fallback to color initialization

This commit is contained in:
arg@mmvi
2006-09-26 13:37:36 +02:00
parent 5c0d28e4ff
commit 3b590beda2
3 changed files with 9 additions and 7 deletions

5
draw.c

@ -76,11 +76,12 @@ 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;
}