Duane Clark wrote:
Fundamentally, the problem is that the X events are handled out of order, because X11DRV_EndGraphicsExposures stripped out particular events (due to copying) without accounting for other pending events that might be relevant (plain old exposure).
Well, that conclusion appears to not be quite correct. I stuck a XPending check at the end of X11DRV_EndGraphicsExposures to see whether there were any pending events, and there were apparently none. So I am not sure why the GraphicsExpose event is coming out before the regular expose event, since in real time, they occurred in the opposite order.