Cocoa: Fixed relative mouse mode when app loses/regains focus (thanks, Eric!).
authorRyan C. Gordon <icculus@icculus.org>
Tue, 26 May 2015 11:38:04 -0400
changeset 9628 065e4ddc8753
parent 9627 74986ccdd090
child 9629 9242a9b29c7d
Cocoa: Fixed relative mouse mode when app loses/regains focus (thanks, Eric!). Fixes Bugzilla #2718.
src/video/cocoa/SDL_cocoawindow.m
--- a/src/video/cocoa/SDL_cocoawindow.m	Tue May 26 11:32:06 2015 -0400
+++ b/src/video/cocoa/SDL_cocoawindow.m	Tue May 26 11:38:04 2015 -0400
@@ -531,13 +531,15 @@
 {
     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;