src/video/cocoa/SDL_cocoamouse.m
changeset 9086 c5e33f9a0d03
parent 8986 1c81316ac642
child 9087 eef2e43f60d1
     1.1 --- a/src/video/cocoa/SDL_cocoamouse.m	Sun Aug 17 14:44:53 2014 -0700
     1.2 +++ b/src/video/cocoa/SDL_cocoamouse.m	Sun Aug 17 14:57:52 2014 -0700
     1.3 @@ -208,41 +208,17 @@
     1.4  }
     1.5  
     1.6  static void
     1.7 -Cocoa_WarpMouse(SDL_Window * window, int x, int y)
     1.8 -{
     1.9 -    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    1.10 -    if ([data->listener isMoving]) {
    1.11 -        DLog("Postponing warp, window being moved.");
    1.12 -        [data->listener setPendingMoveX:x
    1.13 -                                      Y:y];
    1.14 -        return;
    1.15 -    }
    1.16 -
    1.17 -    SDL_Mouse *mouse = SDL_GetMouse();
    1.18 -    CGPoint point = CGPointMake(x + (float)window->x, y + (float)window->y);
    1.19 -
    1.20 -    Cocoa_HandleMouseWarp(point.x, point.y);
    1.21 -
    1.22 -    /* According to the docs, this was deprecated in 10.6, but it's still
    1.23 -     * around. The substitute requires a CGEventSource, but I'm not entirely
    1.24 -     * sure how we'd procure the right one for this event.
    1.25 -     */
    1.26 -    CGSetLocalEventsSuppressionInterval(0.0);
    1.27 -    CGWarpMouseCursorPosition(point);
    1.28 -    CGSetLocalEventsSuppressionInterval(0.25);
    1.29 -
    1.30 -    if (!mouse->relative_mode) {
    1.31 -        /* CGWarpMouseCursorPosition doesn't generate a window event, unlike our
    1.32 -         * other implementations' APIs.
    1.33 -         */
    1.34 -        SDL_SendMouseMotion(mouse->focus, mouse->mouseID, 0, x, y);
    1.35 -    }
    1.36 -}
    1.37 -
    1.38 -static void
    1.39  Cocoa_WarpMouseGlobal(int x, int y)
    1.40  {
    1.41      SDL_Mouse *mouse = SDL_GetMouse();
    1.42 +    if (mouse->focus) {
    1.43 +        SDL_WindowData *data = (SDL_WindowData *) mouse->focus->driverdata;
    1.44 +        if ([data->listener isMoving]) {
    1.45 +            DLog("Postponing warp, window being moved.");
    1.46 +            [data->listener setPendingMoveX:x Y:y];
    1.47 +            return;
    1.48 +        }
    1.49 +    }
    1.50      CGPoint point = CGPointMake((float)x, (float)y);
    1.51  
    1.52      Cocoa_HandleMouseWarp(point.x, point.y);
    1.53 @@ -263,6 +239,12 @@
    1.54      }
    1.55  }
    1.56  
    1.57 +static void
    1.58 +Cocoa_WarpMouse(SDL_Window * window, int x, int y)
    1.59 +{
    1.60 +    Cocoa_WarpMouseGlobal(x + window->x, y + window->y);
    1.61 +}
    1.62 +
    1.63  static int
    1.64  Cocoa_SetRelativeMouseMode(SDL_bool enabled)
    1.65  {