+static void
+load_random_image_cocoa (Screen *screen, Window window, Drawable drawable,
+ void (*callback) (Screen *, Window, Drawable,
+ const char *name, XRectangle *geom,
+ void *closure),
+ void *closure)
+{
+ Display *dpy = DisplayOfScreen (screen);
+ XWindowAttributes xgwa;
+ Bool deskp = get_boolean_resource (dpy, "grabDesktopImages", "Boolean");
+ Bool filep = get_boolean_resource (dpy, "chooseRandomImages", "Boolean");
+ const char *dir = 0;
+ Bool done = False;
+ XRectangle geom;
+ char *name = 0;
+
+ if (!drawable) abort();
+
+ XGetWindowAttributes (dpy, window, &xgwa);
+ {
+ Window r;
+ int x, y;
+ unsigned int w, h, bbw, d;
+ XGetGeometry (dpy, drawable, &r, &x, &y, &w, &h, &bbw, &d);
+ xgwa.width = w;
+ xgwa.height = h;
+ }
+
+ geom.x = 0;
+ geom.y = 0;
+ geom.width = xgwa.width;
+ geom.height = xgwa.height;
+
+# ifndef USE_IPHONE
+ if (filep)
+ dir = get_string_resource (dpy, "imageDirectory", "ImageDirectory");
+
+ if (!dir || !*dir)
+ filep = False;
+# endif /* ! USE_IPHONE */
+
+ if (deskp && filep) {
+ deskp = !(random() & 5); /* if both, desktop 1/5th of the time */
+ filep = !deskp;
+ }
+
+ if (filep && !done) {
+ osx_load_image_file_async (screen, window, drawable, dir,
+ callback, closure);
+ return;
+ }
+
+ if (deskp && !done) {
+ if (osx_grab_desktop_image (screen, window, drawable, &geom)) {
+ name = strdup ("desktop");
+ done = True;
+ }
+ }
+
+ if (! done)
+ draw_colorbars (screen, xgwa.visual, drawable, xgwa.colormap, 0, 0,
+ xgwa.width, xgwa.height, 0, 0); /* #### logo missing */
+
+ /* If we got here, we loaded synchronously, so we're done. */
+ callback (screen, window, drawable, name, &geom, closure);
+ if (name) free (name);
+}
+
+
+#elif defined(HAVE_ANDROID)
+
+/* Loads an image into the Drawable, returning once the image is loaded.
+ */
+static void
+load_random_image_android (Screen *screen, Window window, Drawable drawable,
+ void (*callback) (Screen *, Window, Drawable,
+ const char *name,
+ XRectangle *geom, void *closure),
+ void *closure)