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

Fix #10375: reorder window operations in event handling