- delay = get_integer_resource ("delay", "Integer");
- if (delay < 0) delay = 0;
- speed = get_integer_resource ("speed", "Integer");
- if (speed < 1) speed = 1;
- if (speed > 100) speed = 100;
- rotate_p = get_boolean_resource ("rotate", "Boolean");
- move_p = get_boolean_resource ("move", "Boolean");
- fg = get_pixel_resource ("foreground", "Foreground", dpy, cmap);
- bg = get_pixel_resource ("background", "Background", dpy, cmap);
- gcv.foreground = fg;
- gcv.background = bg;
- draw_gc = XCreateGC (dpy, window, GCForeground|GCBackground, &gcv);
+ st->delay = get_integer_resource (st->dpy, "delay", "Integer");
+ if (st->delay < 0) st->delay = 0;
+ st->speed = get_integer_resource (st->dpy, "speed", "Integer");
+ if (st->speed < 1) st->speed = 1;
+ if (st->speed > 100) st->speed = 100;
+ st->rotate_p = get_boolean_resource (st->dpy, "rotate", "Boolean");
+ st->move_p = get_boolean_resource (st->dpy, "move", "Boolean");
+ if (mono_p)
+ st->ncolors = 2;
+ else
+ st->ncolors = get_integer_resource (st->dpy, "colors", "Colors");
+
+ if (st->ncolors < 2)
+ {
+ st->ncolors = 2;
+ mono_p = True;
+ }
+
+ st->colors = (XColor *) malloc(st->ncolors * sizeof(*st->colors));
+ st->draw_gcs = (GC *) malloc(st->ncolors * sizeof(*st->draw_gcs));
+
+ bg = get_pixel_resource (st->dpy, cmap, "background", "Background");
+ st->colors[0].pixel = bg;
+ st->colors[0].flags = DoRed|DoGreen|DoBlue;
+ XQueryColor(st->dpy, cmap, &st->colors[0]);
+
+ st->ncolors--;
+ make_random_colormap(xgwa.screen, xgwa.visual, cmap,
+ st->colors+1, &st->ncolors, True,
+ True, 0, True);
+ st->ncolors++;
+
+ if (st->ncolors < 2)
+ {
+ st->ncolors = 2;
+ mono_p = True;
+ }
+
+ if (mono_p)
+ {
+ unsigned int fg = get_pixel_resource(st->dpy, cmap, "foreground", "Foreground");
+ st->colors[1].pixel = fg;
+ st->colors[1].flags = DoRed|DoGreen|DoBlue;
+ XQueryColor(st->dpy, cmap, &st->colors[1]);
+ gcv.foreground = fg;
+ gcv.background = bg;
+ st->draw_gcs[0] = XCreateGC (st->dpy, st->window, GCForeground|GCBackground, &gcv);
+ st->draw_gcs[1] = st->draw_gcs[0];
+ }
+ else
+ for( i = 0; i < st->ncolors; i++ )
+ {
+ gcv.foreground = st->colors[i].pixel;
+ gcv.background = bg;
+ st->draw_gcs[i] = XCreateGC (st->dpy, st->window, GCForeground|GCBackground, &gcv);
+ }
+