summaryrefslogtreecommitdiff
path: root/src/wallpaper.c
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-02-27 17:07:08 +0100
committerDaniel Friesel <derf@finalrewind.org>2018-02-27 17:07:08 +0100
commit89aeb953f6b8ce3c7d6974ddd82b51edc2641488 (patch)
treef01673c61f398676ed5274aefaeffe7bc7802c0c /src/wallpaper.c
parent4b01c25946d0ec14d80a3ef2077ac40b78ab68d6 (diff)
parent5965739a0aa6e1f91989a011746c2709cb4e92dc (diff)
Merge branch 'custom-background-color' of https://github.com/ulteq/feh into ulteq-custom-background-color
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 34694ae..cfefb8f 100644
--- a/src/wallpaper.c
+++ b/src/wallpaper.c
@@ -307,15 +307,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);
@@ -339,10 +343,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);
@@ -369,10 +370,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);
@@ -395,10 +393,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);
@@ -474,7 +469,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)