- /* Do the repainting thing. */
- if (f & f_only)
- repaint(DefaultScreenOfDisplay(dpy));
- else {
- for (i = 0; i < ScreenCount(dpy); i++)
- repaint(ScreenOfDisplay(dpy, i));
+ /* Annoyingly, `XClearWindow' uses `ClipByChildren' semantics, and there's
+ * no way to change that. The best idea I can come up with is to drop
+ * windows over the top of each screen and take them away again. The
+ * latter part is easy because they'll disappear when we close the
+ * display.
+ *
+ * Start by making and mapping the windows.
+ */
+ n = f&f_only ? 1 : ScreenCount(dpy);
+ win = xmalloc(n*sizeof(Window));
+ if (f&f_only)
+ win[0] = cover_screen(DefaultScreenOfDisplay(dpy));
+ else for (i = 0; i < n; i++)
+ win[i] = cover_screen(ScreenOfDisplay(dpy, i));
+
+ /* Now we wait until they're all obviously mapped. */
+ while (n) {
+ XNextEvent(dpy, &ev);
+ switch (ev.type) {
+ case MapNotify:
+ w = ev.xmap.window; goto window_visible;
+ case VisibilityNotify: case Expose: case KeyPress: case ButtonPress:
+ w = ev.xany.window; goto window_visible;
+ window_visible:
+ for (i = 0; i < n; i++)
+ if (w == win[i]) { win[i] = win[--n]; break; }
+ break;
+ }