- XGetWindowAttributes (dpy, window, &xgwa);
- cmap = xgwa.colormap;
- global_count = get_integer_resource ("count", "Integer");
- if (global_count < 0) global_count = 0;
- global_inc = get_integer_resource ("increment", "Integer");
- if (global_inc < 0) global_inc = 0;
- xor_p = get_boolean_resource ("xor", "Boolean");
-/* if (mono_p) */ xor_p = True;
- anim_p = get_boolean_resource ("animate", "Boolean");
- delay = get_integer_resource ("delay", "Integer");
+ char *mode_str = 0;
+ st->dpy = dpy;
+ st->window = window;
+ XGetWindowAttributes (st->dpy, st->window, &xgwa);
+ st->cmap = xgwa.colormap;
+ st->global_count = get_integer_resource (st->dpy, "count", "Integer");
+ if (st->global_count < 0) st->global_count = 0;
+ st->global_inc = get_integer_resource (st->dpy, "increment", "Integer");
+ if (st->global_inc < 0) st->global_inc = 0;
+ st->anim_p = get_boolean_resource (st->dpy, "animate", "Boolean");
+ st->delay = get_integer_resource (st->dpy, "delay", "Integer");
+ st->delay2 = get_integer_resource (st->dpy, "delay2", "Integer") * 1000000;
+ mode_str = get_string_resource (st->dpy, "colorMode", "ColorMode");
+ if (! mode_str) cmode = random_mode;
+ else if (!strcmp (mode_str, "seuss")) cmode = seuss_mode;
+ else if (!strcmp (mode_str, "ramp")) cmode = ramp_mode;
+ else if (!strcmp (mode_str, "random")) cmode = random_mode;
+ else {
+ fprintf (stderr,
+ "%s: colorMode must be seuss, ramp, or random, not \"%s\"\n",
+ progname, mode_str);
+ exit (1);
+ }
+
+ if (mono_p) cmode = seuss_mode;
+ if (cmode == random_mode)
+ cmode = ((random()&3) == 1) ? ramp_mode : seuss_mode;
+
+ if (cmode == ramp_mode)
+ st->anim_p = False; /* This combo doesn't work right... */
+
+ st->ncolors = get_integer_resource (st->dpy, "colors", "Colors");
+ if (st->ncolors < 2) st->ncolors = 2;
+ if (st->ncolors <= 2) mono_p = True;
+
+ if (mono_p)
+ st->colors = 0;
+ else
+ st->colors = (XColor *) malloc(sizeof(*st->colors) * (st->ncolors+1));
+
+
+ if (mono_p)
+ ;
+ else if (random() % (cmode == seuss_mode ? 2 : 10))
+ make_uniform_colormap (xgwa.screen, xgwa.visual, st->cmap,
+ st->colors, &st->ncolors,
+ True, 0, True);
+ else
+ make_smooth_colormap (xgwa.screen, xgwa.visual, st->cmap,
+ st->colors, &st->ncolors,
+ True, 0, True);
+
+ if (st->ncolors <= 2) mono_p = True;
+ if (mono_p) cmode = seuss_mode;
+