X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=utils%2Fgrabclient.c;h=4155d8ff2a6370cf22848511b4e86d17dcda1add;hp=0a1d2ac72630aafbf4971baece2d4819a484ec4e;hb=8eb2873d7054e705c4e83f22d18c40946a9e2529;hpb=a1d41b2aa6e18bf9a49b914a99dda8232c5d7762 diff --git a/utils/grabclient.c b/utils/grabclient.c index 0a1d2ac7..4155d8ff 100644 --- a/utils/grabclient.c +++ b/utils/grabclient.c @@ -101,6 +101,26 @@ checkerboard (Screen *screen, Window window) } } +static void +hack_subproc_environment (Display *dpy) +{ + /* Store $DISPLAY into the environment, so that the $DISPLAY variable that + the spawned processes inherit is what we are actually using. + */ + const char *odpy = DisplayString (dpy); + char *ndpy = (char *) malloc(strlen(odpy) + 20); + strcpy (ndpy, "DISPLAY="); + strcat (ndpy, odpy); + + /* Allegedly, BSD 4.3 didn't have putenv(), but nobody runs such systems + any more, right? It's not Posix, but everyone seems to have it. */ +#ifdef HAVE_PUTENV + if (putenv (ndpy)) + abort (); +#endif /* HAVE_PUTENV */ +} + + void grab_screen_image (Screen *screen, Window window) { @@ -134,6 +154,7 @@ grab_screen_image (Screen *screen, Window window) checkerboard (screen, window); XSync (dpy, True); + hack_subproc_environment (dpy); system (cmd); free (cmd); XSync (dpy, True);