summaryrefslogtreecommitdiff
path: root/src/wallpaper.c
diff options
context:
space:
mode:
authorPaul O'Day <odaypaul@gmail.com>2013-03-26 20:52:14 -0700
committerulteq <ulteq@web.de>2018-01-17 10:13:43 +0100
commit5965739a0aa6e1f91989a011746c2709cb4e92dc (patch)
tree7868d5f681dcfeb01e3452700a863ce081fbb718 /src/wallpaper.c
parent0911570bda04e4da541ef095bcdc8cc5cfd57412 (diff)
Allow any XColor values as --image-bg argument
Diffstat (limited to 'src/wallpaper.c')
-rw-r--r--src/wallpaper.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/src/wallpaper.c b/src/wallpaper.c
index c9a3a05..5c50ad8 100644
--- a/src/wallpaper.c
+++ b/src/wallpaper.c
@@ -305,15 +305,19 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
D(("Falling back to XSetRootWindowPixmap\n"));
+ XColor color;
+ Colormap cmap = DefaultColormap(disp, DefaultScreen(disp));
+ if (opt.image_bg)
+ XAllocNamedColor(disp, cmap, (char*) opt.image_bg, &color, &color);
+ else
+ XAllocNamedColor(disp, cmap, "black", &color, &color);
+
if (scaled) {
pmap_d1 = XCreatePixmap(disp, root, scr->width, scr->height, depth);
#ifdef HAVE_LIBXINERAMA
if (opt.xinerama_index >= 0) {
- if (opt.image_bg == IMAGE_BG_WHITE)
- gcval.foreground = WhitePixel(disp, DefaultScreen(disp));
- else
- gcval.foreground = BlackPixel(disp, DefaultScreen(disp));
+ gcval.foreground = color.pixel;
gc = XCreateGC(disp, root, GCForeground, &gcval);
XFillRectangle(disp, pmap_d1, gc, 0, 0, scr->width, scr->height);
XFreeGC(disp, gc);
@@ -337,10 +341,7 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
D(("centering\n"));
pmap_d1 = XCreatePixmap(disp, root, scr->width, scr->height, depth);
- if (opt.image_bg == IMAGE_BG_WHITE)
- gcval.foreground = WhitePixel(disp, DefaultScreen(disp));
- else
- gcval.foreground = BlackPixel(disp, DefaultScreen(disp));
+ gcval.foreground = color.pixel;
gc = XCreateGC(disp, root, GCForeground, &gcval);
XFillRectangle(disp, pmap_d1, gc, 0, 0, scr->width, scr->height);
@@ -367,10 +368,7 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
#ifdef HAVE_LIBXINERAMA
if (opt.xinerama_index >= 0) {
- if (opt.image_bg == IMAGE_BG_WHITE)
- gcval.foreground = WhitePixel(disp, DefaultScreen(disp));
- else
- gcval.foreground = BlackPixel(disp, DefaultScreen(disp));
+ gcval.foreground = color.pixel;
gc = XCreateGC(disp, root, GCForeground, &gcval);
XFillRectangle(disp, pmap_d1, gc, 0, 0, scr->width, scr->height);
XFreeGC(disp, gc);
@@ -393,10 +391,7 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
} else if (filled == 2) {
pmap_d1 = XCreatePixmap(disp, root, scr->width, scr->height, depth);
- if (opt.image_bg == IMAGE_BG_WHITE)
- gcval.foreground = WhitePixel(disp, DefaultScreen(disp));
- else
- gcval.foreground = BlackPixel(disp, DefaultScreen(disp));
+ gcval.foreground = color.pixel;
gc = XCreateGC(disp, root, GCForeground, &gcval);
XFillRectangle(disp, pmap_d1, gc, 0, 0, scr->width, scr->height);
@@ -472,7 +467,7 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
free(path);
}
}
-
+
/* create new display, copy pixmap to new display */
disp2 = XOpenDisplay(NULL);
if (!disp2)