Don't warp the mouse for relative mode when the window doesn't have focus
diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c
index a776bcc..184942e 100644
--- a/src/events/SDL_mouse.c
+++ b/src/events/SDL_mouse.c
@@ -358,7 +358,9 @@ SDL_PrivateSendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relativ
mouse->last_y = center_y;
return 0;
}
- SDL_WarpMouseInWindow(window, center_x, center_y);
+ if (window && (window->flags & SDL_WINDOW_INPUT_FOCUS) != 0) {
+ SDL_WarpMouseInWindow(window, center_x, center_y);
+ }
}
if (relative) {
diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c
index 3fbd5a8..426024a 100644
--- a/src/video/windows/SDL_windowsevents.c
+++ b/src/video/windows/SDL_windowsevents.c
@@ -663,7 +663,8 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
if (GetMouseMessageSource() != SDL_MOUSE_EVENT_SOURCE_TOUCH &&
lParam != data->last_pointer_update) {
SDL_SendMouseMotion(data->window, 0, 0, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
- if (isWin10FCUorNewer && mouse->relative_mode_warp) {
+ if (isWin10FCUorNewer && mouse->relative_mode_warp &&
+ (data->window->flags & SDL_WINDOW_INPUT_FOCUS)) {
/* To work around #3931, Win10 bug introduced in Fall Creators Update, where
SetCursorPos() (SDL_WarpMouseInWindow()) doesn't reliably generate mouse events anymore,
after each windows mouse event generate a fake event for the middle of the window