+ init_cos_tab(st);
+ setup_X(st);
+
+ st->ncolors = get_integer_resource (disp, "colors", "Colors");
+ if (0 == st->ncolors) /* English spelling? */
+ st->ncolors = get_integer_resource (disp, "colours", "Colors");
+
+ if (st->ncolors > sizeof(st->ctab)/sizeof(*st->ctab))
+ st->ncolors = sizeof(st->ctab)/sizeof(*st->ctab);
+
+ if (st->oily)
+ init_oily_colors(st);
+ else
+ init_linear_colors(st);
+
+ if (st->transparent && st->light > 0) {
+ int maxbits;
+ st->draw_transparent = draw_transparent_light;
+ set_mask(st->visual->red_mask, &st->rmask, &st->rshift);
+ set_mask(st->visual->green_mask, &st->gmask, &st->gshift);
+ set_mask(st->visual->blue_mask, &st->bmask, &st->bshift);
+ if (st->rmask == 0) st->draw_transparent = draw_transparent_vanilla;
+
+ /* Adjust the shift value "light" when we don't have 8 bits per colour */
+ maxbits = MIN(MIN(BITCOUNT(st->rmask), BITCOUNT(st->gmask)), BITCOUNT(st->bmask));
+ st->light -= 8-maxbits;
+ if (st->light < 0) st->light = 0;
+ } else {
+ if (st->grayscale_p)
+ {
+ set_mask(st->visual->red_mask, &st->rmask, &st->rshift);
+ set_mask(st->visual->green_mask, &st->gmask, &st->gshift);
+ set_mask(st->visual->blue_mask, &st->bmask, &st->bshift);
+ }
+ st->draw_transparent = draw_transparent_vanilla;
+ }
+
+ if (!st->transparent)
+ init_ripples(st, 0, -SPLASH); /* Start off without any drops */
+
+ return st;
+}
+
+static unsigned long
+ripples_draw (Display *dpy, Window window, void *closure)
+{
+ struct state *st = (struct state *) closure;
+
+ 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 */
+ XWindowAttributes xgwa;
+ XGetWindowAttributes(st->dpy, st->window, &xgwa);
+ st->start_time = time ((time_t) 0);
+ st->orig_map = XGetImage (st->dpy, st->window, 0, 0,
+ xgwa.width, xgwa.height,
+ ~0L, ZPixmap);
+ init_ripples(st, 0, -SPLASH); /* Start off without any drops */
+ }
+ return st->delay;
+ }
+
+ if (!st->img_loader &&
+ st->start_time + st->duration < time ((time_t) 0)) {
+ XWindowAttributes xgwa;
+ XGetWindowAttributes(st->dpy, st->window, &xgwa);
+ st->img_loader = load_image_async_simple (0, xgwa.screen, st->window,
+ st->window, 0, 0);
+ st->start_time = time ((time_t) 0);
+ return st->delay;
+ }
+
+ if (st->rate > 0 && (st->iterations % st->rate) == 0)
+ add_drop(st, ripple_blob, -SPLASH);
+ if (st->stir)
+ add_drop(st, ripple_stir, -SPLASH);
+ if (st->box > 0 && (random() % st->box) == 0)
+ add_drop(st, ripple_box, -SPLASH);
+
+ ripple(st);
+ DisplayImage(st);
+
+ st->iterations++;
+
+ return st->delay;
+}
+
+
+static void
+ripples_reshape (Display *dpy, Window window, void *closure,
+ unsigned int w, unsigned int h)
+{
+}
+
+static Bool
+ripples_event (Display *dpy, Window window, void *closure, XEvent *event)
+{
+ return False;
+}
+
+static void
+ripples_free (Display *dpy, Window window, void *closure)
+{
+ struct state *st = (struct state *) closure;
+ free (st);
+}
+
+static const char *ripples_defaults[] =