Handle interaction between auto capture and the SDL_CaptureMouse() API

Fixes https://github.com/libsdl-org/SDL/issues/5457
This commit is contained in:
Sam Lantinga 2022-04-05 15:05:07 -07:00
parent 0e198a8799
commit 86acb1a347
3 changed files with 55 additions and 31 deletions

View file

@ -638,6 +638,7 @@ SDL_SetKeyboardFocus(SDL_Window * window)
/* old window must lose an existing mouse capture. */
if (keyboard->focus->flags & SDL_WINDOW_MOUSE_CAPTURE) {
SDL_CaptureMouse(SDL_FALSE); /* drop the capture. */
SDL_UpdateMouseCapture(SDL_TRUE);
SDL_assert(!(keyboard->focus->flags & SDL_WINDOW_MOUSE_CAPTURE));
}