--- src/video/cocoa/SDL_cocoamouse.m 2014-08-08 00:09:06.000000000 -0500 +++ src/video/cocoa/SDL_cocoamouse.m 2014-08-08 17:02:15.000000000 -0500 @@ -207,6 +207,7 @@ return 0; } +#if !ASL_SDL static void Cocoa_WarpMouse(SDL_Window * window, int x, int y) { @@ -238,11 +239,23 @@ SDL_SendMouseMotion(mouse->focus, mouse->mouseID, 0, x, y); } } +#endif // !ASL_SDL static void Cocoa_WarpMouseGlobal(int x, int y) { SDL_Mouse *mouse = SDL_GetMouse(); +#if ASL_SDL // Repeat window dragging fix from old Cocoa_WarpMouse above. + if (mouse->focus) { + SDL_WindowData *data = (SDL_WindowData *) mouse->focus->driverdata; + if ([data->listener isMoving]) { + DLog("Postponing warp, window being moved."); + [data->listener setPendingMoveX:x + Y:y]; + return; + } + } +#endif // ASL_SDL CGPoint point = CGPointMake((float)x, (float)y); Cocoa_HandleMouseWarp(point.x, point.y); @@ -263,6 +276,14 @@ } } +#if ASL_SDL // Cocoa_WarpMouse is just a special case of Cocoa_WarpMouseGlobal. +static void +Cocoa_WarpMouse(SDL_Window * window, int x, int y) +{ + Cocoa_WarpMouseGlobal(x + window->x, y + window->y); +} +#endif // ASL_SDL + static int Cocoa_SetRelativeMouseMode(SDL_bool enabled) { --- src/video/cocoa/SDL_cocoawindow.m 2014-08-08 00:09:06.000000000 -0500 +++ src/video/cocoa/SDL_cocoawindow.m 2014-08-08 17:02:15.000000000 -0500 @@ -114,8 +114,16 @@ static void ConvertNSRect(NSScreen *screen, BOOL fullscreen, NSRect *r) { +#if ASL_SDL + // This essentially reverts the mainline SDL change that redefines global coord + // space for windows on the main display to be relative to the bottom of the + // menubar instead of the top of the screen. That change breaks at least + // Cocoa_WarpMouse and probably other things as well. + r->origin.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - r->origin.y - r->size.height; +#else // ASL_SDL NSRect visibleScreen = fullscreen ? [screen frame] : [screen visibleFrame]; r->origin.y = (visibleScreen.origin.y + visibleScreen.size.height) - r->origin.y - r->size.height; +#endif // ASL_SDL } static void @@ -404,6 +412,15 @@ isMoving = NO; SDL_Mouse *mouse = SDL_GetMouse(); +#if ASL_SDL // pendingWindowWarpX & Y are now global coords. + if (pendingWindowWarpX != INT_MAX && pendingWindowWarpY != INT_MAX) { + mouse->WarpMouseGlobal(pendingWindowWarpX, pendingWindowWarpY); + pendingWindowWarpX = pendingWindowWarpY = INT_MAX; + } + if (mouse->relative_mode && !mouse->relative_mode_warp && mouse->focus == _data->window) { + mouse->SetRelativeMouseMode(SDL_TRUE); + } +#else // ASL_SDL if (pendingWindowWarpX >= 0 && pendingWindowWarpY >= 0) { mouse->WarpMouse(_data->window, pendingWindowWarpX, pendingWindowWarpY); pendingWindowWarpX = pendingWindowWarpY = -1; @@ -411,6 +428,7 @@ if (mouse->relative_mode && SDL_GetMouseFocus() == _data->window) { mouse->SetRelativeMouseMode(SDL_TRUE); } +#endif // ASL_SDL } } @@ -428,7 +446,11 @@ - (void)windowWillMove:(NSNotification *)aNotification { if ([_data->nswindow isKindOfClass:[SDLWindow class]]) { +#if ASL_SDL + pendingWindowWarpX = pendingWindowWarpY = INT_MAX; +#else // ASL_SDL pendingWindowWarpX = pendingWindowWarpY = -1; +#endif // ASL_SDL isMoving = YES; } } @@ -515,7 +537,11 @@ { SDL_Window *window = _data->window; SDL_Mouse *mouse = SDL_GetMouse(); +#if ASL_SDL + if (mouse->relative_mode && !mouse->relative_mode_warp && ![self isMoving]) { +#else // ASL_SDL if (mouse->relative_mode && ![self isMoving]) { +#endif // ASL_SDL mouse->SetRelativeMouseMode(SDL_TRUE); } @@ -547,7 +573,11 @@ - (void)windowDidResignKey:(NSNotification *)aNotification { SDL_Mouse *mouse = SDL_GetMouse(); +#if ASL_SDL + if (mouse->relative_mode && !mouse->relative_mode_warp) { +#else // ASL_SDL if (mouse->relative_mode) { +#endif // ASL_SDL mouse->SetRelativeMouseMode(SDL_FALSE); }