Ever since I enabled the advanced desktop effects on Ubuntu I have had problems with repaints of various windows. This has been an issue on two different laptops for multiple versions of Ubuntu. It is due to some problem between the nVidia drivers I have been using to enable the fancy effects and the compositing window manager. If the effects are disabled the repaint issues go away.

Today I decided to google for this and encountered the ubuntu bug 269904 which covers this. From this, buried in among 300 comments is a suggestion to enable a workaround that solves the problem for me.

In the CompizConfig Settings Manager, under the Utilities section select the Workarounds page and check the "Force synchronization between X and GLX" button. This forces a more extensive repaint and fixes all the trouble I see in Emacs and other heavily scrolled windows.