Fix for the mouse not correctly being grabbed in some situations, particularly if the window does not have focus during loading.