- return (strcmp (res_class, "Background")
- ? WhitePixel (dpy, DefaultScreen (dpy))
- : BlackPixel (dpy, DefaultScreen (dpy)));
+
+ {
+ Bool black_p = (strlen(res_class) >= 10 &&
+ !strcasecmp ("Background",
+ res_class + strlen(res_class) - 10));
+ if (!ok)
+ fprintf (stderr, ": using %s.\n", (black_p ? "black" : "white"));
+ color.flags = DoRed|DoGreen|DoBlue;
+ color.red = color.green = color.blue = (black_p ? 0 : 0xFFFF);
+ if (XAllocColor (dpy, cmap, &color))
+ return (unsigned int) color.pixel;
+ else
+ {
+ fprintf (stderr, "%s: couldn't allocate %s either!\n", progname,
+ (black_p ? "black" : "white"));
+ /* We can't use BlackPixel/WhitePixel here, because we don't know
+ what screen we're allocating on (only an issue when running inside
+ the xscreensaver daemon: for hacks, DefaultScreen is fine.)
+ */
+ return 0;
+ }
+ }