From a70a94e0b3d5c4788535ac7796bc5814095c36d3 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 15 Oct 2021 18:11:19 -0700 Subject: [PATCH] Don't send a mouse leave event if the mouse is outside the window when gaining focus and in relative mode. --- src/video/windows/SDL_windowsevents.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index 3a41e1421..d30642a1b 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -403,9 +403,12 @@ WIN_UpdateFocus(SDL_Window *window) SDL_SetKeyboardFocus(window); - GetCursorPos(&cursorPos); - ScreenToClient(hwnd, &cursorPos); - SDL_SendMouseMotion(window, 0, 0, cursorPos.x, cursorPos.y); + /* In relative mode we are guaranteed to have mouse focus if we have keyboard focus */ + if (!SDL_GetMouse()->relative_mode) { + GetCursorPos(&cursorPos); + ScreenToClient(hwnd, &cursorPos); + SDL_SendMouseMotion(window, 0, 0, cursorPos.x, cursorPos.y); + } WIN_CheckAsyncMouseRelease(data); WIN_UpdateClipCursor(window);