- if (!get_boolean_resource ("peek", "Boolean"))
- p = XCreatePixmap (st->dpy, st->window,
- st->xgwa.width, st->xgwa.height,
- st->xgwa.depth);
-
- load_random_image (st->xgwa.screen, st->window,
- (p ? p : st->window), 0, 0);
- st->image = XGetImage (st->dpy, (p ? p : st->window), 0, 0,
- st->xgwa.width, st->xgwa.height, ~0L, ZPixmap);
- if (p) XFreePixmap (st->dpy, p);
- XSync (st->dpy, False);
- XSetWindowBackground (st->dpy, st->window, st->bg_color);
- if (!p) sleep (2);
+ if (st->loading_pixmap) abort();
+ if (st->img_loader) abort();
+ if (!get_boolean_resource (st->dpy, "peek", "Boolean"))
+ st->loading_pixmap = XCreatePixmap (st->dpy, st->window,
+ st->xgwa.width, st->xgwa.height,
+ st->xgwa.depth);
+
+ XClearWindow (st->dpy, st->window);
+ st->img_loader = load_image_async_simple (0, st->xgwa.screen,
+ st->window,
+ (st->loading_pixmap
+ ? st->loading_pixmap
+ : st->window),
+ 0, 0);