From 0517b61ed681fc20684aec63e08644d1c13b75d0 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 19 Mar 2022 11:00:00 -0700 Subject: [PATCH] Relative mouse mode is tied to the window with keyboard focus This isn't obvious, but makes sense when thinking about how games actually use it. This is also in line with how Windows mouse relative mode is implemented. Fixes https://github.com/libsdl-org/SDL/issues/5340 --- src/video/cocoa/SDL_cocoamouse.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/video/cocoa/SDL_cocoamouse.m b/src/video/cocoa/SDL_cocoamouse.m index 4c107d816..a2f14bfca 100644 --- a/src/video/cocoa/SDL_cocoamouse.m +++ b/src/video/cocoa/SDL_cocoamouse.m @@ -262,9 +262,9 @@ Cocoa_SetRelativeMouseMode(SDL_bool enabled) /* We will re-apply the relative mode when the window gets focus, if it * doesn't have focus right now. */ - SDL_Window *window = SDL_GetMouseFocus(); + SDL_Window *window = SDL_GetKeyboardFocus(); if (!window) { - return 0; + return 0; } /* We will re-apply the relative mode when the window finishes being moved,