From 733eb53c6fae29c32fe52bc841e47050afc44534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20P=2E=20Tjern=C3=B8?= Date: Tue, 23 Apr 2013 18:47:38 -0700 Subject: [PATCH] Mac: Make mouse movement smooth at edge of window when grabbed. There's a limit of one update every 250ms when warping the mouse, and we can work around that by disassociating the cursor & the mouse before issuing our warp, then re-associating them. --- src/video/cocoa/SDL_cocoawindow.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index 5e9c599fe..56eaa5134 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -392,7 +392,14 @@ 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. + */ + CGAssociateMouseAndMouseCursorPosition(NO); CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, cgpoint); + CGAssociateMouseAndMouseCursorPosition(YES); } } SDL_SendMouseMotion(window, 0, 0, x, y);