Fix the client behavior when showing or hiding a surface

Reduce the chances of seeing a bad frame.

Change-Id: Idac3450d92210fc5fc33cb68862b089964c9a8ce
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>