From 22358fddd13645235e5f0f87dfd89be82f1e12de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20P=2E=20Tjern=C3=B8?= Date: Thu, 25 Apr 2013 18:40:22 -0700 Subject: [PATCH] Mac: Don't supress mousemoves after warp. By default, synthesizing events supresses real events for a quarter second. This makes for some wonky behavior. --HG-- extra : histedit_source : 769156e3eba77c601de006c5aad1cdc1febe1d6c --- src/video/cocoa/SDL_cocoamouse.m | 7 +++++++ src/video/cocoa/SDL_cocoawindow.m | 10 +++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/video/cocoa/SDL_cocoamouse.m b/src/video/cocoa/SDL_cocoamouse.m index acce0a2f4..23e8796e0 100644 --- a/src/video/cocoa/SDL_cocoamouse.m +++ b/src/video/cocoa/SDL_cocoamouse.m @@ -192,7 +192,14 @@ Cocoa_WarpMouse(SDL_Window * window, int x, int y) point.x = (float)window->x + x; point.y = (float)window->y + y; + + /* According to the docs, this was deprecated in 10.6, but it's still + * around. The substitute requires a CGEventSource, but I'm not entirely + * sure how we'd procure the right one for this event. + */ + CGSetLocalEventsSuppressionInterval(0.0); CGWarpMouseCursorPosition(point); + CGSetLocalEventsSuppressionInterval(0.25); /* CGWarpMouseCursorPosition doesn't generate a window event, unlike our * other implementations' APIs. diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index 56eaa5134..dee8bbae7 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -393,13 +393,13 @@ static __inline__ void ConvertNSRect(NSRect *r) cgpoint.x = window->x + x; cgpoint.y = window->y + y; - /* We have to disassociate the curosr & the mouse before issuing - * this cursor warp, otherwise it gets limited to one update per - * 250ms, and looks very choppy. + /* According to the docs, this was deprecated in 10.6, but it's still + * around. The substitute requires a CGEventSource, but I'm not entirely + * sure how we'd procure the right one for this event. */ - CGAssociateMouseAndMouseCursorPosition(NO); + CGSetLocalEventsSuppressionInterval(0.0); CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, cgpoint); - CGAssociateMouseAndMouseCursorPosition(YES); + CGSetLocalEventsSuppressionInterval(0.25); } } SDL_SendMouseMotion(window, 0, 0, x, y);