-/* xscreensaver, Copyright (c) 1992-2008 Jamie Zawinski <jwz@jwz.org>
+/* xscreensaver, Copyright (c) 1992-2012 Jamie Zawinski <jwz@jwz.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
# include <X11/Intrinsic.h> /* for XtInputId, etc */
#endif /* !HAVE_COCOA */
+#include <sys/stat.h>
+
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
if (putenv (ndpy))
abort ();
#endif /* HAVE_PUTENV */
+
+ /* don't free (ndpy) -- some implementations of putenv (BSD 4.4,
+ glibc 2.0) copy the argument, but some (libc4,5, glibc 2.1.2, MacOS)
+ do not. So we must leak it (and/or the previous setting). Yay.
+ */
}
Screen *screen;
Window xwindow;
Drawable drawable;
+ char *directory;
void (*callback) (Screen *, Window, Drawable,
const char *name, XRectangle *geom,
void *closure);
*/
struct pipe_closure *clo2 = (struct pipe_closure *) closure;
char buf[10240];
+ const char *dir = clo2->directory;
+ char *absfile = 0;
fgets (buf, sizeof(buf)-1, clo2->pipe);
pclose (clo2->pipe);
clo2->pipe = 0;
Display *dpy = DisplayOfScreen (clo2->screen);
XRectangle geom;
+ if (*buf && *buf != '/') /* pathname is relative to dir. */
+ {
+ absfile = malloc (strlen(dir) + strlen(buf) + 10);
+ strcpy (absfile, dir);
+ if (dir[strlen(dir)-1] != '/')
+ strcat (absfile, "/");
+ strcat (absfile, buf);
+ }
+
if (! osx_load_image_file (clo2->screen, clo2->xwindow, clo2->drawable,
- buf, &geom)) {
+ (absfile ? absfile : buf), &geom)) {
/* unable to load image - draw colorbars
*/
XWindowAttributes xgwa;
Window r;
int x, y;
unsigned int w, h, bbw, d;
+ struct stat st;
+
+ /* Log something to syslog so we can tell the difference between
+ corrupted images and broken symlinks. */
+ if (!*buf)
+ fprintf (stderr, "%s: no image filename found\n", progname);
+ else if (! stat (buf, &st))
+ fprintf (stderr, "%s: %s: unparsable\n", progname, buf);
+ else
+ {
+ char buf2[2048];
+ sprintf (buf2, "%.255s: %.1024s", progname, buf);
+ perror (buf2);
+ }
+
XGetGeometry (dpy, clo2->drawable, &r, &x, &y, &w, &h, &bbw, &d);
draw_colorbars (clo2->screen, xgwa.visual, clo2->drawable, xgwa.colormap,
0, 0, w, h);
geom.height = h;
}
+ if (absfile) free (absfile);
clo2->callback (clo2->screen, clo2->xwindow, clo2->drawable, buf, &geom,
clo2->closure);
clo2->callback = 0;
+ free (clo2->directory);
free (clo2);
}
Display *dpy = DisplayOfScreen (screen);
struct pipe_closure *clo2 = (struct pipe_closure *) calloc (1, sizeof(*clo2));
+ clo2->directory = strdup (dir);
clo2->pipe = open_image_name_pipe (dir);
clo2->id = XtAppAddInput (XtDisplayToApplicationContext (dpy),
fileno (clo2->pipe),
Bool done = False;
XRectangle geom_ret_2;
char *name_ret_2 = 0;
+
+# ifdef USE_IPHONE
+ /* Currently, only screen-grabbing is implemented, not loading of
+ images from the iPhone Photo Library. See osxgrabscreen.m.
+ */
+ deskp = True;
+ filep = False;
+# endif
if (!drawable) abort();
}
if (deskp && !done) {
- osx_grab_desktop_image (screen, window, drawable);
- if (name_ret)
- *name_ret = strdup ("desktop");
- done = True;
+ if (osx_grab_desktop_image (screen, window, drawable, &geom_ret_2)) {
+ if (name_ret)
+ *name_ret = strdup ("desktop");
+ done = True;
+ }
}
- if (! done) {
+ if (! done)
draw_colorbars (screen, xgwa.visual, drawable, xgwa.colormap,
0, 0, xgwa.width, xgwa.height);
- done = True;
- }
if (callback) {
/* If we got here, we loaded synchronously even though they wanted async.