window: fix focus issue when creating event

https://bugzilla.gnome.org/show_bug.cgi?id=738858