Skip to content

Commit

Permalink
Cocoa: Fixed relative mouse mode when app loses/regains focus (thanks…
Browse files Browse the repository at this point in the history
…, Eric!).

Fixes Bugzilla #2718.
  • Loading branch information
icculus committed May 26, 2015
1 parent d074a53 commit 80916e0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/video/cocoa/SDL_cocoawindow.m
Expand Up @@ -531,13 +531,15 @@ - (void)windowDidBecomeKey:(NSNotification *)aNotification
{ {
SDL_Window *window = _data->window; SDL_Window *window = _data->window;
SDL_Mouse *mouse = SDL_GetMouse(); SDL_Mouse *mouse = SDL_GetMouse();
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. */ /* 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); SDL_SetKeyboardFocus(window);


if (mouse->relative_mode && !mouse->relative_mode_warp && ![self isMoving]) {
mouse->SetRelativeMouseMode(SDL_TRUE);
}

/* If we just gained focus we need the updated mouse position */ /* If we just gained focus we need the updated mouse position */
if (!mouse->relative_mode) { if (!mouse->relative_mode) {
NSPoint point; NSPoint point;
Expand Down

0 comments on commit 80916e0

Please sign in to comment.