+
+ /* do this many lines at a time without pausing */
+ int col_chunk = st->iteration * 2 + 1;
+
+ if (st->iteration > st->iterations)
+ init_map (st);
+
+ if (st->cx == 0)
+ {
+ st->xnextStep = st->xstep / 2;
+ st->ynextStep = st->ystep / 2;
+ }
+
+ for (i = 0; i < col_chunk; i++)
+ {
+ int x1, x2, y1, y2;
+ int y;
+ int x = st->cx;
+
+ x1 = x + st->xnextStep;
+ if (x1 < 0)
+ x1 = st->xmax-1;
+ else if (x1 >= st->xmax)
+ x1 = 0;
+
+ x2 = x + st->xstep;
+ if (x2 < 0)
+ x2 = st->xmax-1;
+ else if (x2 >= st->xmax)
+ x2 = 0;
+
+ for (y = 0; y < st->ymax; y += st->ystep)
+ {
+ unsigned int pixel, qpixels [4];
+
+ y1 = y + st->ynextStep;
+ if (y1 < 0)
+ y1 = st->ymax-1;
+ else if (y1 >= st->ymax)
+ y1 = 0;
+
+ y2 = y + st->ystep;
+ if (y2 < 0)
+ y2 = st->ymax-1;
+ else if (y2 >= st->ymax)
+ y2 = 0;
+
+ qpixels [0] = st->colors [HEIGHT_TO_PIXEL (CELL (x, y))].pixel;
+ qpixels [1] = st->colors [HEIGHT_TO_PIXEL (CELL (x, y2))].pixel;
+ qpixels [2] = st->colors [HEIGHT_TO_PIXEL (CELL (x2, y))].pixel;
+ qpixels [3] = st->colors [HEIGHT_TO_PIXEL (CELL (x2, y2))].pixel;
+
+ pixel = set (st, x, y1, st->iteration,
+ ((int) CELL (x, y) + (int) CELL (x, y2) + 1) / 2);
+
+ if (! mono_p &&
+ (pixel != qpixels[0] || pixel != qpixels[1] ||
+ pixel != qpixels[2] || pixel != qpixels[3]))
+ draw (st, x, y1, pixel, st->ynextStep);
+
+ pixel = set (st, x1, y, st->iteration,
+ ((int) CELL (x, y) + (int) CELL (x2, y) + 1) / 2);
+ if (! mono_p &&
+ (pixel != qpixels[0] || pixel != qpixels[1] ||
+ pixel != qpixels[2] || pixel != qpixels[3]))
+ draw (st, x1, y, pixel, st->ynextStep);
+
+ pixel = set (st, x1, y1, st->iteration,
+ ((int) CELL (x, y) + (int) CELL (x, y2) +
+ (int) CELL (x2, y) + (int) CELL (x2, y2) + 2)
+ / 4);
+ if (! mono_p &&
+ (pixel != qpixels[0] || pixel != qpixels[1] ||
+ pixel != qpixels[2] || pixel != qpixels[3]))
+ draw (st, x1, y1, pixel, st->ynextStep);
+ }
+
+ st->cx += st->xstep;
+ if (st->cx >= st->xmax)
+ break;
+ }
+
+ if (st->cx >= st->xmax)
+ {
+ st->cx = 0;
+ st->xstep = st->xnextStep;
+ st->ystep = st->ynextStep;
+
+ st->iteration++;
+
+ if (st->iteration > st->iterations)
+ this_delay = st->delay * 1000000;
+
+ if (mono_p)
+ floyd_steinberg (st); /* in mono, do all drawing at the end */
+ }
+
+ return this_delay;
+}
+
+
+static void
+imsmap_reshape (Display *dpy, Window window, void *closure,
+ unsigned int w, unsigned int h)
+{
+ struct state *st = (struct state *) closure;
+ init_map (st);
+}
+
+
+static Bool
+imsmap_event (Display *dpy, Window window, void *closure, XEvent *event)
+{
+ struct state *st = (struct state *) closure;
+ if (screenhack_event_helper (dpy, window, event))