Correct placement of window event flush for window state

A bad cherry-pick meant that 155363 put some code window flushing code
inside the wrong function. This fixes where the flush should occur.

Change-Id: I468d9881d08c358cf559a12d52b18702db3cb1e0
Reviewed-by: Andy Nichols <andy.nichols@digia.com>