Don't drop mouse focus on WM_MOUSELEAVE if the mouse is in relative mode; mouse-level is not meaningful for that case.

Do drop mouse focus when keyboard focus is lost if the mouse is in relative mode.
main
Sam Lantinga 2022-07-05 21:42:24 -07:00
parent 0253a45029
commit adf3ce7c01
1 changed files with 8 additions and 2 deletions

View File

@ -451,6 +451,10 @@ WIN_UpdateFocus(SDL_Window *window, SDL_bool expect_focus)
data->in_window_deactivation = SDL_TRUE;
SDL_SetKeyboardFocus(NULL);
/* In relative mode we are guaranteed to not have mouse focus if we don't have keyboard focus */
if (SDL_GetMouse()->relative_mode) {
SDL_SetMouseFocus(NULL);
}
WIN_ResetDeadKeys();
if (GetClipCursor(&rect) && SDL_memcmp(&rect, &data->cursor_clipped_rect, sizeof(rect)) == 0) {
@ -943,8 +947,10 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
}
/* When WM_MOUSELEAVE is fired we can be assured that the cursor has left the window */
SDL_SetMouseFocus(NULL);
if (!SDL_GetMouse()->relative_mode) {
/* When WM_MOUSELEAVE is fired we can be assured that the cursor has left the window */
SDL_SetMouseFocus(NULL);
}
}
/* Once we get WM_MOUSELEAVE we're guaranteed that the window is no longer tracked */