diff -urN feh_orig/src/wallpaper.c feh/src/wallpaper.c --- feh_orig/src/wallpaper.c 2022-05-05 13:36:26.178993801 +0200 +++ feh/src/wallpaper.c 2022-05-06 11:30:26.723017583 +0200 @@ -441,16 +441,13 @@ XAllocNamedColor(disp, cmap, "black", &color, &color); if (scaled) { + pmap_d1 = XCreatePixmap(disp, root, scr->width, scr->height, depth); + gcval.foreground = color.pixel; + gc = XCreateGC(disp, root, GCForeground, &gcval); + XFillRectangle(disp, pmap_d1, gc, 0, 0, scr->width, scr->height); #ifdef HAVE_LIBXINERAMA - if (opt.xinerama_index >= 0) { - gcval.foreground = color.pixel; - gc = XCreateGC(disp, root, GCForeground, &gcval); - XFillRectangle(disp, pmap_d1, gc, 0, 0, scr->width, scr->height); - XFreeGC(disp, gc); - } - if (opt.xinerama && xinerama_screens) { for (i = 0; i < num_xinerama_screens; i++) { if (opt.xinerama_index < 0 || opt.xinerama_index == i) { @@ -464,6 +461,9 @@ #endif /* HAVE_LIBXINERAMA */ feh_wm_set_bg_scaled(pmap_d1, im, use_filelist, 0, 0, scr->width, scr->height); + + XFreeGC(disp, gc); + } else if (centered) { D(("centering\n")); @@ -493,15 +493,11 @@ } else if (filled == 1) { pmap_d1 = XCreatePixmap(disp, root, scr->width, scr->height, depth); + gcval.foreground = color.pixel; + gc = XCreateGC(disp, root, GCForeground, &gcval); + XFillRectangle(disp, pmap_d1, gc, 0, 0, scr->width, scr->height); #ifdef HAVE_LIBXINERAMA - if (opt.xinerama_index >= 0) { - gcval.foreground = color.pixel; - gc = XCreateGC(disp, root, GCForeground, &gcval); - XFillRectangle(disp, pmap_d1, gc, 0, 0, scr->width, scr->height); - XFreeGC(disp, gc); - } - if (opt.xinerama && xinerama_screens) { for (i = 0; i < num_xinerama_screens; i++) { if (opt.xinerama_index < 0 || opt.xinerama_index == i) { @@ -516,6 +512,8 @@ feh_wm_set_bg_filled(pmap_d1, im, use_filelist , 0, 0, scr->width, scr->height); + XFreeGC(disp, gc); + } else if (filled == 2) { pmap_d1 = XCreatePixmap(disp, root, scr->width, scr->height, depth);