+ Display *dpy = DisplayOfScreen (screen);
+ XWindowAttributes xgwa;
+ XRectangle geom;
+ char *name = 0;
+ char *data = 0;
+ int width = 0;
+ int height = 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;
+
+ data = jwxyz_load_random_image (dpy, &width, &height, &name);
+ if (! data)
+ draw_colorbars (screen, xgwa.visual, drawable, xgwa.colormap,
+ 0, 0, xgwa.width, xgwa.height);
+ else
+ {
+ XImage *img = XCreateImage (dpy, xgwa.visual, 32,
+ ZPixmap, 0, data, width, height, 0, 0);
+ XGCValues gcv;
+ GC gc;
+ gcv.foreground = BlackPixelOfScreen (screen);
+ gc = XCreateGC (dpy, drawable, GCForeground, &gcv);
+ XFillRectangle (dpy, drawable, gc, 0, 0, xgwa.width, xgwa.height);
+ XPutImage (dpy, drawable, gc, img, 0, 0,
+ (xgwa.width - width) / 2,
+ (xgwa.height - height) / 2,
+ width, height);
+ XDestroyImage (img);
+ XFreeGC (dpy, gc);
+ }
+
+ callback (screen, window, drawable, name, &geom, closure);
+ if (name) free (name);
+}
+
+#endif /* HAVE_ANDROID */
+
+
+
+/* Writes the string "Loading..." in the middle of the screen.
+ This will presumably get blown away when the image finally loads,
+ minutes or hours later...
+
+ This is called by load_image_async_simple() but not by load_image_async(),
+ since it is assumed that hacks that are loading more than one image
+ *at one time* will be doing something more clever than just blocking
+ with a blank screen.
+ */
+static void
+print_loading_msg (Screen *screen, Window window)
+{
+ Display *dpy = DisplayOfScreen (screen);
+ XWindowAttributes xgwa;
+ XGCValues gcv;
+ XFontStruct *f = 0;
+ GC gc;
+ char *fn = get_string_resource (dpy, "labelFont", "Font");
+ const char *text = "Loading...";
+ int w;
+
+ if (!fn) fn = get_string_resource (dpy, "titleFont", "Font");
+ if (!fn) fn = get_string_resource (dpy, "font", "Font");
+ if (!fn) fn = strdup ("-*-times-bold-r-normal-*-180-*");
+ f = XLoadQueryFont (dpy, fn);
+ if (!f) f = XLoadQueryFont (dpy, "fixed");
+ if (!f) abort();
+ free (fn);
+ fn = 0;
+
+ XGetWindowAttributes (dpy, window, &xgwa);
+ w = XTextWidth (f, text, (int) strlen(text));
+
+ gcv.foreground = get_pixel_resource (dpy, xgwa.colormap,
+ "foreground", "Foreground");
+ gcv.background = get_pixel_resource (dpy, xgwa.colormap,
+ "background", "Background");
+ gcv.font = f->fid;
+ gc = XCreateGC (dpy, window, GCFont | GCForeground | GCBackground, &gcv);
+ XDrawImageString (dpy, window, gc,
+ (xgwa.width - w) / 2,
+ (xgwa.height - (f->ascent + f->descent)) / 2 + f->ascent,
+ text, (int) strlen(text));
+ XFreeFont (dpy, f);
+ XFreeGC (dpy, gc);
+ XSync (dpy, False);