+static void *
+starfish_init (Display *dpy, Window window)
+{
+ struct state *st = (struct state *) calloc (1, sizeof(*st));
+ char *s;
+ st->dpy = dpy;
+ st->window = window;
+ st->delay = get_integer_resource (st->dpy, "delay", "Delay");
+ st->delay2 = get_integer_resource (st->dpy, "delay2", "Delay") * 1000000;
+/* st->duration = get_seconds_resource (st->dpy, "duration", "Seconds");*/
+ st->duration = get_integer_resource (st->dpy, "duration", "Seconds");
+ st->direction = (random() & 1) ? 1 : -1;
+
+ s = get_string_resource (st->dpy, "mode", "Mode");
+ if (s && !strcasecmp (s, "blob"))
+ st->blob_p = True;
+ else if (s && !strcasecmp (s, "zoom"))
+ st->blob_p = False;
+ else if (!s || !*s || !strcasecmp (s, "random"))
+ st->blob_p = !(random() % 3);
+ else
+ fprintf (stderr, "%s: mode must be blob, zoom, or random", progname);
+
+ if (st->blob_p)
+ st->delay *= 3;
+
+ st->starfish = reset_starfish (st);
+ return st;
+}
+
+static unsigned long
+starfish_draw (Display *dpy, Window window, void *closure)
+{
+ struct state *st = (struct state *) closure;
+ struct starfish *s = st->starfish;
+ time_t now;
+
+ run_starfish (st, s);
+
+ if (st->duration > 0)
+ {
+ if (st->start_time == 0)
+ st->start_time = time ((time_t) 0);
+ now = time ((time_t) 0);
+ if (st->start_time + st->duration < now)
+ {
+ st->start_time = now;
+
+ free_starfish (s);
+
+ /* Every now and then, pick new colors; otherwise, just build
+ a new starfish with the current colors. */
+ if (! (random () % 10))
+ s = reset_starfish (st);
+ else
+ s = make_window_starfish (st);
+
+ st->starfish = s;
+ }
+ }
+
+ return st->delay;
+}
+
+static void
+starfish_reshape (Display *dpy, Window window, void *closure,
+ unsigned int w, unsigned int h)
+{
+}
+
+static Bool
+starfish_event (Display *dpy, Window window, void *closure, XEvent *event)
+{
+ return False;
+}
+
+static void
+starfish_free (Display *dpy, Window window, void *closure)
+{
+ struct state *st = (struct state *) closure;
+ free (st);
+}
+