summaryrefslogtreecommitdiff
path: root/src/wallpaper.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/wallpaper.c')
-rw-r--r--src/wallpaper.c113
1 files changed, 83 insertions, 30 deletions
diff --git a/src/wallpaper.c b/src/wallpaper.c
index 3e19c41..a11a50d 100644
--- a/src/wallpaper.c
+++ b/src/wallpaper.c
@@ -292,27 +292,36 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
Atom prop_root, prop_esetroot, type;
int format, i;
unsigned long length, after;
- unsigned char *data_root, *data_esetroot;
+ unsigned char *data_root = NULL, *data_esetroot = NULL;
Pixmap pmap_d1, pmap_d2;
gib_list *l;
/* string for sticking in ~/.fehbg */
char *fehbg = NULL;
+ char fehbg_args[512];
+ fehbg_args[0] = '\0';
char *home;
char filbuf[4096];
- char fehbg_xinerama[] = "--no-xinerama";
char *bgfill = NULL;
bgfill = opt.image_bg == IMAGE_BG_WHITE ? "--image-bg white" : "--image-bg black" ;
+#ifdef HAVE_LIBXINERAMA
+ if (opt.xinerama) {
+ if (opt.xinerama_index >= 0) {
+ snprintf(fehbg_args, sizeof(fehbg_args),
+ "--xinerama-index %d", opt.xinerama_index);
+ }
+ }
+ else
+ snprintf(fehbg_args, sizeof(fehbg_args), "--no-xinerama");
+#endif /* HAVE_LIBXINERAMA */
+
/* local display to set closedownmode on */
Display *disp2;
Window root2;
int depth2;
int in, out, w, h;
- if (opt.xinerama)
- fehbg_xinerama[0] = '\0';
-
D(("Falling back to XSetRootWindowPixmap\n"));
/* Put the filename in filbuf between ' and escape ' in the filename */
@@ -357,16 +366,30 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
pmap_d1 = XCreatePixmap(disp, root, scr->width, scr->height, depth);
#ifdef HAVE_LIBXINERAMA
- if (opt.xinerama && xinerama_screens)
- for (i = 0; i < num_xinerama_screens; i++)
- feh_wm_set_bg_scaled(pmap_d1, im, use_filelist,
- xinerama_screens[i].x_org, xinerama_screens[i].y_org,
- xinerama_screens[i].width, xinerama_screens[i].height);
+ 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));
+ 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) {
+ feh_wm_set_bg_scaled(pmap_d1, im, use_filelist,
+ xinerama_screens[i].x_org, xinerama_screens[i].y_org,
+ xinerama_screens[i].width, xinerama_screens[i].height);
+ }
+ }
+ }
else
#endif /* HAVE_LIBXINERAMA */
feh_wm_set_bg_scaled(pmap_d1, im, use_filelist,
0, 0, scr->width, scr->height);
- fehbg = estrjoin(" ", "feh", fehbg_xinerama, "--bg-scale", filbuf, NULL);
+ fehbg = estrjoin(" ", "feh", fehbg_args, "--bg-scale", filbuf, NULL);
} else if (centered) {
D(("centering\n"));
@@ -380,11 +403,15 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
XFillRectangle(disp, pmap_d1, gc, 0, 0, scr->width, scr->height);
#ifdef HAVE_LIBXINERAMA
- if (opt.xinerama && xinerama_screens)
- for (i = 0; i < num_xinerama_screens; i++)
- feh_wm_set_bg_centered(pmap_d1, im, use_filelist,
- xinerama_screens[i].x_org, xinerama_screens[i].y_org,
- xinerama_screens[i].width, xinerama_screens[i].height);
+ if (opt.xinerama && xinerama_screens) {
+ for (i = 0; i < num_xinerama_screens; i++) {
+ if (opt.xinerama_index < 0 || opt.xinerama_index == i) {
+ feh_wm_set_bg_centered(pmap_d1, im, use_filelist,
+ xinerama_screens[i].x_org, xinerama_screens[i].y_org,
+ xinerama_screens[i].width, xinerama_screens[i].height);
+ }
+ }
+ }
else
#endif /* HAVE_LIBXINERAMA */
feh_wm_set_bg_centered(pmap_d1, im, use_filelist,
@@ -392,24 +419,38 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
XFreeGC(disp, gc);
- fehbg = estrjoin(" ", "feh", fehbg_xinerama, bgfill, "--bg-center", filbuf, NULL);
+ fehbg = estrjoin(" ", "feh", fehbg_args, bgfill, "--bg-center", filbuf, NULL);
} else if (filled == 1) {
pmap_d1 = XCreatePixmap(disp, root, scr->width, scr->height, depth);
#ifdef HAVE_LIBXINERAMA
- if (opt.xinerama && xinerama_screens)
- for (i = 0; i < num_xinerama_screens; i++)
- feh_wm_set_bg_filled(pmap_d1, im, use_filelist,
- xinerama_screens[i].x_org, xinerama_screens[i].y_org,
- xinerama_screens[i].width, xinerama_screens[i].height);
+ 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));
+ 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) {
+ feh_wm_set_bg_filled(pmap_d1, im, use_filelist,
+ xinerama_screens[i].x_org, xinerama_screens[i].y_org,
+ xinerama_screens[i].width, xinerama_screens[i].height);
+ }
+ }
+ }
else
#endif /* HAVE_LIBXINERAMA */
feh_wm_set_bg_filled(pmap_d1, im, use_filelist
, 0, 0, scr->width, scr->height);
- fehbg = estrjoin(" ", "feh", fehbg_xinerama, "--bg-fill", filbuf, NULL);
+ fehbg = estrjoin(" ", "feh", fehbg_args, "--bg-fill", filbuf, NULL);
} else if (filled == 2) {
@@ -422,11 +463,15 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
XFillRectangle(disp, pmap_d1, gc, 0, 0, scr->width, scr->height);
#ifdef HAVE_LIBXINERAMA
- if (opt.xinerama && xinerama_screens)
- for (i = 0; i < num_xinerama_screens; i++)
- feh_wm_set_bg_maxed(pmap_d1, im, use_filelist,
- xinerama_screens[i].x_org, xinerama_screens[i].y_org,
- xinerama_screens[i].width, xinerama_screens[i].height);
+ if (opt.xinerama && xinerama_screens) {
+ for (i = 0; i < num_xinerama_screens; i++) {
+ if (opt.xinerama_index < 0 || opt.xinerama_index == i) {
+ feh_wm_set_bg_maxed(pmap_d1, im, use_filelist,
+ xinerama_screens[i].x_org, xinerama_screens[i].y_org,
+ xinerama_screens[i].width, xinerama_screens[i].height);
+ }
+ }
+ }
else
#endif /* HAVE_LIBXINERAMA */
feh_wm_set_bg_maxed(pmap_d1, im, use_filelist,
@@ -434,7 +479,7 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
XFreeGC(disp, gc);
- fehbg = estrjoin(" ", "feh", fehbg_xinerama, bgfill, "--bg-max", filbuf, NULL);
+ fehbg = estrjoin(" ", "feh", fehbg_args, bgfill, "--bg-max", filbuf, NULL);
} else {
if (use_filelist)
@@ -465,8 +510,9 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
}
free(path);
}
- free(fehbg);
}
+
+ free(fehbg);
/* create new display, copy pixmap to new display */
disp2 = XOpenDisplay(NULL);
@@ -504,6 +550,13 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
}
}
}
+
+ if (data_root)
+ XFree(data_root);
+
+ if (data_esetroot)
+ XFree(data_esetroot);
+
/* This will locate the property, creating it if it doesn't exist */
prop_root = XInternAtom(disp2, "_XROOTPMAP_ID", False);
prop_esetroot = XInternAtom(disp2, "ESETROOT_PMAP_ID", False);