static void osx_load_image_file_async (Screen *screen, Window xwindow, Drawable drawable, const char *dir, void (*callback) (Screen *, Window, Drawable, const char *name, XRectangle *geom, void *closure), void *closure) { xscreensaver_getimage_data *clo2 = (xscreensaver_getimage_data *) calloc (1, sizeof(*clo2)); clo2->screen = screen; clo2->window = xwindow; clo2->drawable = drawable; clo2->callback = callback; clo2->closure = closure; # ifndef USE_IPHONE /* Desktop OSX */ clo2->directory = strdup (dir); clo2->pipe = open_image_name_pipe (dir); clo2->pipe_id = XtAppAddInput (XtDisplayToApplicationContext ( DisplayOfScreen (screen)), fileno (clo2->pipe), (XtPointer) (XtInputReadMask | XtInputExceptMask), xscreensaver_getimage_file_cb, (XtPointer) clo2); # else /* USE_IPHONE */ ios_load_random_image (ios_load_random_image_cb, clo2); # endif /* USE_IPHONE */ }
static void osx_load_image_file_async (Screen *screen, Window xwindow, Drawable drawable, const char *dir, void (*callback) (Screen *, Window, Drawable, const char *name, XRectangle *geom, void *closure), void *closure) { # if 0 /* do it synchronously */ FILE *pipe = open_image_name_pipe (dir); char buf[10240]; *buf = 0; fgets (buf, sizeof(buf)-1, pipe); pclose (pipe); /* strip trailing newline */ int L = strlen(buf); while (L > 0 && (buf[L-1] == '\r' || buf[L-1] == '\n')) buf[--L] = 0; XRectangle geom; if (! osx_load_image_file (screen, xwindow, drawable, buf, &geom)) { /* draw colorbars */ abort(); } callback (screen, xwindow, drawable, buf, &geom, closure); # else /* do it asynchronously */ struct pipe_closure *clo2 = (struct pipe_closure *) calloc (1, sizeof(*clo2)); clo2->screen = screen; clo2->xwindow = xwindow; clo2->drawable = drawable; clo2->callback = callback; clo2->closure = closure; # ifndef USE_IPHONE clo2->directory = strdup (dir); clo2->pipe = open_image_name_pipe (dir); clo2->id = XtAppAddInput (XtDisplayToApplicationContext ( DisplayOfScreen (screen)), fileno (clo2->pipe), (XtPointer) (XtInputReadMask | XtInputExceptMask), pipe_cb, (XtPointer) clo2); # else /* USE_IPHONE */ ios_load_random_image (ios_load_random_image_cb, clo2); # endif /* USE_IPHONE */ # endif }