- Pixmap p;
- XWindowAttributes xgwa;
- XGCValues gcv;
- GC gc;
- XGetWindowAttributes (dpy, window, &xgwa);
- *widthP = xgwa.width;
- *heightP = xgwa.height;
-
- grab_screen_image(xgwa.screen, window);
- p = XCreatePixmap(dpy, window, *widthP, *heightP, xgwa.depth);
- gcv.function = GXcopy;
- gc = XCreateGC (dpy, window, GCFunction, &gcv);
- XCopyArea (dpy, window, p, gc, 0, 0, *widthP, *heightP, 0, 0);
-
- /* Reset the window's background color... */
- XSetWindowBackground (dpy, window,
- get_pixel_resource ("background", "Background",
- dpy, xgwa.colormap));
- XCopyArea (dpy, p, window, gc, 0, 0, *widthP, *heightP, 0, 0);
- XFreeGC (dpy, gc);
-
- return p;
+ struct state *st = (struct state *) closure;
+ int this_delay = st->delay;
+ int qwad;
+
+ if (st->img_loader) /* still loading */
+ {
+ st->img_loader = load_image_async_simple (st->img_loader, 0, 0, 0, 0, 0);
+
+ if (!st->img_loader) { /* just finished */
+ st->first_time = 0;
+ st->loaded_p = True;
+ st->qwad = -1;
+ st->start_time = time ((time_t *) 0);
+ blitspin_init_2 (st);
+ }
+
+ /* Rotate nothing if the very first image is not yet loaded */
+ if (! st->loaded_p)
+ return this_delay;
+ }
+
+ if (!st->img_loader &&
+ st->load_ext_p &&
+ st->start_time + st->duration < time ((time_t *) 0)) {
+ /* Start a new image loading, but keep rotating the old image
+ until the new one arrives. */
+ st->img_loader = load_image_async_simple (0, st->xgwa.screen, st->window,
+ st->bitmap, 0, 0);
+ }
+
+ if (st->qwad == -1)
+ {
+ bitblt(st, st->mask, st->mask, clear,0,0, st->size, st->size, 0,0);
+ bitblt(st, st->mask, st->mask, set, 0,0, st->size>>1, st->size>>1, 0,0);
+ st->qwad = st->size>>1;
+ }
+
+ if (st->first_time)
+ {
+ st->first_time = 0;
+ display (st, st->self);
+ return st->delay2;
+ }
+
+ /* for (st->qwad = st->size>>1; st->qwad > 0; st->qwad>>=1) */
+
+ qwad = st->qwad;
+
+ copy_to (mask, 0, 0, temp, copy); /* 1 */
+ copy_to (mask, 0, qwad, temp, or); /* 2 */
+ copy_to (self, 0, 0, temp, and); /* 3 */
+ copy_to (temp, 0, 0, self, xor); /* 4 */
+ copy_from (temp, qwad, 0, self, xor); /* 5 */
+ copy_from (self, qwad, 0, self, or); /* 6 */
+ copy_to (temp, qwad, 0, self, xor); /* 7 */
+ copy_to (self, 0, 0, temp, copy); /* 8 */
+ copy_from (temp, qwad, qwad, self, xor); /* 9 */
+ copy_to (mask, 0, 0, temp, and); /* A */
+ copy_to (temp, 0, 0, self, xor); /* B */
+ copy_to (temp, qwad, qwad, self, xor); /* C */
+ copy_from (mask, qwad>>1, qwad>>1, mask, and); /* D */
+ copy_to (mask, qwad, 0, mask, or); /* E */
+ copy_to (mask, 0, qwad, mask, or); /* F */
+ display (st, st->self);
+
+ st->qwad >>= 1;
+ if (st->qwad == 0) /* done with this round */
+ {
+ st->qwad = -1;
+ this_delay = st->delay2;
+ }
+
+ return this_delay;