Fix #10375: reorder window operations in event handling
Merge pull request #828 from mtbc/trac-10375

Fix #10375: reorder window operations in event handling