When I start my game (SDL2+Ogre) and alt+tab around the time of the window creation, sometimes the SDL_WINDOW_INPUT_FOCUS flag will be true even though the window isn’t even visible. I get this flag using SDL_GetWindowFlags. If I then call SDL_SetRelativeMouseMode(SDL_TRUE), the cursor is forced at the centre of the screen in Windows, even though I’m just in regular Windows and the game isn’t visible.
I don’t know the exact repro case: it happens sometimes, but not always when I try to trigger this issue by doing alt+tab around the time of window creation.
Is this a bug in SDL, or something that I’m doing wrong?
How can I know whether it’s safe to call SDL_SetRelativeMouseMode without trapping the user outside the game?