Fix video_getSetWindowGrab(): need to raise the window, and wait for focus gained

This commit is contained in:
Sylvain 2023-03-20 12:34:36 +01:00 committed by Sylvain Becker
parent d4d26e0ddb
commit f30a182de2

View File

@ -501,6 +501,7 @@ static int video_getSetWindowGrab(void *arg)
const char *title = "video_getSetWindowGrab Test Window";
SDL_Window *window;
SDL_bool originalMouseState, originalKeyboardState;
SDL_bool hasFocusGained = SDL_FALSE;
/* Call against new test window */
window = createVideoSuiteTestWindow(title);
@ -508,6 +509,23 @@ static int video_getSetWindowGrab(void *arg)
return TEST_ABORTED;
}
/* Need to raise the window to have and SDL_EVENT_WINDOW_FOCUS_GAINED,
* so that the window gets the flags SDL_WINDOW_INPUT_FOCUS,
* so that it can be "grabbed" */
SDL_RaiseWindow(window);
{
SDL_Event evt;
SDL_zero(evt);
while (SDL_PollEvent(&evt)) {
if (evt.type == SDL_EVENT_WINDOW_FOCUS_GAINED) {
hasFocusGained = SDL_TRUE;
}
}
}
SDLTest_AssertCheck(hasFocusGained == SDL_TRUE, "Expectded window with focus");
/* Get state */
originalMouseState = SDL_GetWindowMouseGrab(window);
SDLTest_AssertPass("Call to SDL_GetWindowMouseGrab()");