From 80916e01f3f77d0bfa6302ddbafbfeea5ec02805 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 26 May 2015 11:38:04 -0400 Subject: [PATCH] Cocoa: Fixed relative mouse mode when app loses/regains focus (thanks, Eric!). Fixes Bugzilla #2718. --- src/video/cocoa/SDL_cocoawindow.m | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index 2a02041d9..fb23f3c87 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -531,13 +531,15 @@ SetWindowStyle(SDL_Window * window, unsigned int style) { SDL_Window *window = _data->window; SDL_Mouse *mouse = SDL_GetMouse(); + + /* We're going to get keyboard events, since we're key. */ + /* This needs to be done before restoring the relative mouse mode. */ + SDL_SetKeyboardFocus(window); + if (mouse->relative_mode && !mouse->relative_mode_warp && ![self isMoving]) { mouse->SetRelativeMouseMode(SDL_TRUE); } - /* We're going to get keyboard events, since we're key. */ - SDL_SetKeyboardFocus(window); - /* If we just gained focus we need the updated mouse position */ if (!mouse->relative_mode) { NSPoint point;