Don't send a mouse leave event if the mouse is outside the window when gaining focus and in relative mode.

This commit is contained in:
Sam Lantinga 2021-10-15 18:11:19 -07:00
parent c583055acb
commit a70a94e0b3
1 changed files with 6 additions and 3 deletions

View File

@ -403,9 +403,12 @@ WIN_UpdateFocus(SDL_Window *window)
SDL_SetKeyboardFocus(window); SDL_SetKeyboardFocus(window);
GetCursorPos(&cursorPos); /* In relative mode we are guaranteed to have mouse focus if we have keyboard focus */
ScreenToClient(hwnd, &cursorPos); if (!SDL_GetMouse()->relative_mode) {
SDL_SendMouseMotion(window, 0, 0, cursorPos.x, cursorPos.y); GetCursorPos(&cursorPos);
ScreenToClient(hwnd, &cursorPos);
SDL_SendMouseMotion(window, 0, 0, cursorPos.x, cursorPos.y);
}
WIN_CheckAsyncMouseRelease(data); WIN_CheckAsyncMouseRelease(data);
WIN_UpdateClipCursor(window); WIN_UpdateClipCursor(window);