- while (1)
- {
- XGetWindowAttributes (dpy, window, &xgwa);
- XFillRectangle(dpy, window, bgc, 0, 0, xgwa.width, xgwa.height);
- deco (dpy, window, xgwa.colormap, fgc, bgc,
- 0, 0, xgwa.width, xgwa.height, 0);
- XSync (dpy, True);
-
- if (!delay) continue;
- if (!writable)
- sleep (delay);
- else
- {
- time_t start = time((time_t) 0);
- while (start - delay < time((time_t) 0))
- {
- rotate_colors (dpy, xgwa.colormap, colors, ncolors, 1);
- if (cycle_delay)
- usleep (cycle_delay);
- }
- }
- }
+ st->mondrian = get_boolean_resource(dpy, "mondrian", "Boolean");
+ if (st->mondrian) {
+ /* Mondrian, if true, overrides several other options. */
+ mondrian_set_sizes(st, st->xgwa.width, st->xgwa.height);
+
+ /** set up red-yellow-blue-black-white colormap and fgc **/
+ make_mondrian_colormap(st->xgwa.screen, st->xgwa.visual,
+ st->xgwa.colormap,
+ st->colors, &st->ncolors, True, 0, True);
+
+ /** put white in several cells **/
+ /** set min-height and min-width to about 10% of total w/h **/
+ }
+ else if (st->smoothColors)
+ make_smooth_colormap (st->xgwa.screen, st->xgwa.visual,
+ st->xgwa.colormap,
+ st->colors, &st->ncolors, True, 0, True);
+ else
+ make_random_colormap (st->xgwa.screen, st->xgwa.visual,
+ st->xgwa.colormap,
+ st->colors, &st->ncolors, False, True, 0, True);
+
+ gcv.line_width = st->old_line_width = st->line_width;
+ XChangeGC(dpy, st->fgc, GCLineWidth, &gcv);
+
+ return st;
+}
+
+static unsigned long
+deco_draw (Display *dpy, Window window, void *closure)
+{
+ struct state *st = (struct state *) closure;
+ XFillRectangle (dpy, window, st->bgc, 0, 0, st->xgwa.width, st->xgwa.height);
+ if (st->mondrian) {
+ mondrian_set_sizes(st, st->xgwa.width, st->xgwa.height);
+ if (st->line_width != st->old_line_width) {
+ XSetLineAttributes(dpy, st->fgc, st->line_width,
+ LineSolid, CapButt, JoinBevel);
+ st->old_line_width = st->line_width;
+ }
+ }
+ deco (dpy, window, st, 0, 0, st->xgwa.width, st->xgwa.height, 0);
+ return 1000000 * st->delay;
+}
+
+static void
+deco_reshape (Display *dpy, Window window, void *closure,
+ unsigned int w, unsigned int h)
+{
+ struct state *st = (struct state *) closure;
+ st->xgwa.width = w;
+ st->xgwa.height = h;