Skip to content
Permalink
Browse files

Cocoa: Fixed relative mouse mode when app loses/regains focus (thanks…

…, Eric!).

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

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

0 comments on commit 80916e0

Please sign in to comment.