Mac: Fix incorrect relative jump on focus / start.
authorJørgen P. Tjernø <jorgen@valvesoftware.com>
Tue, 04 Jun 2013 14:54:49 -0700
changeset 7271963d2ba35cfe
parent 7270 76df5476a6ce
child 7272 c502531983c7
Mac: Fix incorrect relative jump on focus / start.

We should no longer send huge jumps on relative mode focus changes if
the cursor was moved around, or on initial start.

Fixes http://bugzilla.libsdl.org/show_bug.cgi?id=1836
src/video/cocoa/SDL_cocoamouse.m
src/video/cocoa/SDL_cocoawindow.m
     1.1 --- a/src/video/cocoa/SDL_cocoamouse.m	Tue Jun 04 13:53:55 2013 -0700
     1.2 +++ b/src/video/cocoa/SDL_cocoamouse.m	Tue Jun 04 14:54:49 2013 -0700
     1.3 @@ -224,10 +224,12 @@
     1.4      CGWarpMouseCursorPosition(point);
     1.5      CGSetLocalEventsSuppressionInterval(0.25);
     1.6  
     1.7 -    /* CGWarpMouseCursorPosition doesn't generate a window event, unlike our
     1.8 -     * other implementations' APIs.
     1.9 -     */
    1.10 -    SDL_SendMouseMotion(mouse->focus, mouse->mouseID, 0, x, y);
    1.11 +    if (!mouse->relative_mode) {
    1.12 +        /* CGWarpMouseCursorPosition doesn't generate a window event, unlike our
    1.13 +         * other implementations' APIs.
    1.14 +         */
    1.15 +        SDL_SendMouseMotion(mouse->focus, mouse->mouseID, 0, x, y);
    1.16 +    }
    1.17  }
    1.18  
    1.19  static int
     2.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Tue Jun 04 13:53:55 2013 -0700
     2.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Tue Jun 04 14:54:49 2013 -0700
     2.3 @@ -240,12 +240,13 @@
     2.4  - (void)windowDidBecomeKey:(NSNotification *)aNotification
     2.5  {
     2.6      SDL_Window *window = _data->window;
     2.7 +    SDL_Mouse *mouse = SDL_GetMouse();
     2.8  
     2.9      /* We're going to get keyboard events, since we're key. */
    2.10      SDL_SetKeyboardFocus(window);
    2.11  
    2.12      /* If we just gained focus we need the updated mouse position */
    2.13 -    {
    2.14 +    if (!mouse->relative_mode) {
    2.15          NSPoint point;
    2.16          int x, y;
    2.17