Mac: Don't disassociate cursor if window is moving / doesn't have focus.
authorJørgen P. Tjernø <jorgen@valvesoftware.com>
Wed, 26 Feb 2014 16:10:52 -0800
changeset 8262acc0dcf38b3d
parent 8261 841b66e4397a
child 8263 e22c4959e385
Mac: Don't disassociate cursor if window is moving / doesn't have focus.

Bug: https://bugzilla.libsdl.org/show_bug.cgi?id=2396
src/video/cocoa/SDL_cocoamouse.m
     1.1 --- a/src/video/cocoa/SDL_cocoamouse.m	Wed Feb 26 11:35:02 2014 -0800
     1.2 +++ b/src/video/cocoa/SDL_cocoamouse.m	Wed Feb 26 16:10:52 2014 -0800
     1.3 @@ -244,8 +244,23 @@
     1.4  static int
     1.5  Cocoa_SetRelativeMouseMode(SDL_bool enabled)
     1.6  {
     1.7 +    /* We will re-apply the relative mode when the window gets focus, if it
     1.8 +     * doesn't have focus right now.
     1.9 +     */
    1.10 +    SDL_Window *window = SDL_GetMouseFocus();
    1.11 +    if (!window) {
    1.12 +      return 0;
    1.13 +    }
    1.14 +
    1.15 +    /* We will re-apply the relative mode when the window finishes being moved,
    1.16 +     * if it is being moved right now.
    1.17 +     */
    1.18 +    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    1.19 +    if ([data->listener isMoving]) {
    1.20 +        return;
    1.21 +    }
    1.22 +
    1.23      CGError result;
    1.24 -
    1.25      if (enabled) {
    1.26          DLog("Turning on.");
    1.27          result = CGAssociateMouseAndMouseCursorPosition(NO);