- XFillRectangle (st->dpy, st->window, st->backgroundGC, 0, 0,
- st->windowWidth, st->windowHeight);
- st->backgroundImage =
- XGetImage (st->dpy, st->window, 0, 0, st->windowWidth, st->windowHeight,
- ~0L, ZPixmap);
-
- st->start_time = time ((time_t) 0);
+ /* On MacOS X11, XGetImage on a Window often gets an inexplicable BadMatch,
+ possibly due to the window manager having occluded something? It seems
+ nondeterministic. Loading the image into a pixmap instead fixes it. */
+ if (st->pm) XFreePixmap (st->dpy, st->pm);
+ st->pm = XCreatePixmap (st->dpy, st->window,
+ xwa->width, xwa->height, xwa->depth);
+
+ st->start_time = time ((time_t *) 0);