I'm working on an application that shows an image sequence alternating with short time delays (on the order of 500 - 1000 milliseconds). The X instructions I'm using are:
window = XCreateSimpleWindow (display, screen, etc);
XMapWindow (display, window);
XFlush (display);
while {
XClearWindow(display);
XSetWindowBackgroundPixmap (display, window, pixmap);
XFlush (display);
nanosleep (delay)
}
with a different pixmap and delay period each time. What I'm finding is that the initial (blank) window is displayed correctly, but subsequent images are displayed at the beginning of the NEXT iteration; thus, the blank window stays up through the first loop iteration and call to nanosleep, followed by the first image (displayed at the time the second image should be up), and the last one is not displayed at all. It's as if the XFlush() command doesn't work for the last event entered. However, when I checked there were no pending events in the queue.
Of course I can work around this but I never liked inelegant solutions. Are there any obvious errors in this simple scheme?
XFree86 version is 4.3.0.1 running on Debian Sarge.