May it help: the exact same thing happened sometimes on windows, I remember for some old games, when the game window is considered "fullscreen" from its point of view, but not from the system point of view (I guess), so mouse is "trapped" by the game and you can't move cursor outside the game window. Like with Virtual Pool 3 for instance.
As nothing looks wrong with your code, what have you done when running the game ?
Is it always consistent ?
Do you launch it from VS ? From the executable inside the build directory ?