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 9628065e4ddc8753
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
     1.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Tue May 26 11:32:06 2015 -0400
     1.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Tue May 26 11:38:04 2015 -0400
     1.3 @@ -531,13 +531,15 @@
     1.4  {
     1.5      SDL_Window *window = _data->window;
     1.6      SDL_Mouse *mouse = SDL_GetMouse();
     1.7 +
     1.8 +    /* We're going to get keyboard events, since we're key. */
     1.9 +    /* This needs to be done before restoring the relative mouse mode. */
    1.10 +    SDL_SetKeyboardFocus(window);
    1.11 +
    1.12      if (mouse->relative_mode && !mouse->relative_mode_warp && ![self isMoving]) {
    1.13          mouse->SetRelativeMouseMode(SDL_TRUE);
    1.14      }
    1.15  
    1.16 -    /* We're going to get keyboard events, since we're key. */
    1.17 -    SDL_SetKeyboardFocus(window);
    1.18 -
    1.19      /* If we just gained focus we need the updated mouse position */
    1.20      if (!mouse->relative_mode) {
    1.21          NSPoint point;