Fix the swap surface buffer code
Make sure the swap surface code only gets called when the app
starts painting. This patch is less intrusive.