From 795744fc75318640909f731a5124f6d2e34a7e54 Mon Sep 17 00:00:00 2001 From: FriendlyAI Date: Fri, 7 Jan 2022 10:11:46 -0500 Subject: [PATCH] Turn off relative mouse before window checks as well --- src/video/cocoa/SDL_cocoamouse.m | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/video/cocoa/SDL_cocoamouse.m b/src/video/cocoa/SDL_cocoamouse.m index 30cf84a8c..8b5a18483 100644 --- a/src/video/cocoa/SDL_cocoamouse.m +++ b/src/video/cocoa/SDL_cocoamouse.m @@ -263,9 +263,12 @@ Cocoa_SetRelativeMouseMode(SDL_bool enabled) if (enabled) { DLog("Turning on."); result = CGAssociateMouseAndMouseCursorPosition(NO); - if (result != kCGErrorSuccess) { - return SDL_SetError("CGAssociateMouseAndMouseCursorPosition() failed"); - } + } else { + DLog("Turning off."); + result = CGAssociateMouseAndMouseCursorPosition(YES); + } + if (result != kCGErrorSuccess) { + return SDL_SetError("CGAssociateMouseAndMouseCursorPosition() failed"); } /* We will re-apply the non-relative mode when the window gets focus, if it @@ -284,15 +287,6 @@ Cocoa_SetRelativeMouseMode(SDL_bool enabled) return 0; } - if (!enabled) { - DLog("Turning off."); - result = CGAssociateMouseAndMouseCursorPosition(YES); - if (result != kCGErrorSuccess) { - return SDL_SetError("CGAssociateMouseAndMouseCursorPosition() failed"); - } - } - - /* The hide/unhide calls are redundant most of the time, but they fix * https://bugzilla.libsdl.org/show_bug.cgi?id=2550 */