I encountered this problem when coding smooth scrolling for rxvt
But before X server executes the XCopyArea, the source region is somehow changed. This results in "foreign pixels" being moved. "Foreign" as pixels inherited from another window which was obscuring ours at some point.
This can happen in these cases:
Solution: record the change/movements (keep a list of pairs request-number . movement, and when we finally get the Expose event -- a rectangle, apply the movement to it too, and refresh pixels on the resulting rectangle. Discard the pairs when we get event w/ that request commited (this is indicated in the 'serial' slot of the event).
When issueing a sequence of XCopyArea, I have to keep a sequence of this info (request-sequence-number . movement); discard them when I know that the request-sequence-number has been committed (i.e. by watching the 'serial' slot in events), and on Expose I have to apply a mapping to see where will the exposed rectangle be after the already issued sequence of (pixel moving) commands.
Keep a list of (rectangle & move). When we get a GraphicsExpose for a move, we start from that move, and mark as wrong all rectangles which are images under composition of the moves (in the list).
http://mail.gnome.org/archives/gtk-list/1997-December/msg00254.html
related (pixmap -> window blits vs NoExpose) http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6480051