Mac: Don't supress mousemoves after warp.
authorJørgen P. Tjernø <jorgen@valvesoftware.com>
Thu, 25 Apr 2013 18:40:22 -0700
changeset 7113 7b4b596b3cfb
parent 7112 a1a723edea64
child 7114 02b2fe147478
Mac: Don't supress mousemoves after warp. By default, synthesizing events supresses real events for a quarter second. This makes for some wonky behavior.
src/video/cocoa/SDL_cocoamouse.m
src/video/cocoa/SDL_cocoawindow.m
--- a/src/video/cocoa/SDL_cocoamouse.m	Thu Apr 25 18:40:31 2013 -0700
+++ b/src/video/cocoa/SDL_cocoamouse.m	Thu Apr 25 18:40:22 2013 -0700
@@ -192,7 +192,14 @@
 
     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.
--- a/src/video/cocoa/SDL_cocoawindow.m	Thu Apr 25 18:40:31 2013 -0700
+++ b/src/video/cocoa/SDL_cocoawindow.m	Thu Apr 25 18:40:22 2013 -0700
@@ -393,13 +393,13 @@
             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);