Quartz: Fix mouse warping freezing for 250+ milliseconds. SDL-1.2
authorRyan C. Gordon <icculus@icculus.org>
Mon, 16 Jan 2012 14:27:47 -0500
branchSDL-1.2
changeset 6224 6f013dd0add1
parent 6218 f114f1434ff6
child 6225 e1264a758d50
Quartz: Fix mouse warping freezing for 250+ milliseconds. Fixes Bugzilla #1375. Thanks to Jeremiah Morris for the patch!
src/video/quartz/SDL_QuartzWM.m
--- a/src/video/quartz/SDL_QuartzWM.m	Sun Jan 15 03:13:08 2012 -0500
+++ b/src/video/quartz/SDL_QuartzWM.m	Mon Jan 16 14:27:47 2012 -0500
@@ -230,7 +230,6 @@
 #endif /* Dead code */
 
 void  QZ_PrivateWarpCursor (_THIS, int x, int y) {
-    CGEventSourceRef evsrc = CGEventSourceCreate(kCGEventSourceStateCombinedSessionState);
     NSPoint p;
     CGPoint cgp;
     
@@ -238,9 +237,11 @@
     cgp = QZ_PrivateSDLToCG (this, &p);
     
     /* this is the magic call that fixes cursor "freezing" after warp */
-    CGEventSourceSetLocalEventsSuppressionInterval(evsrc, 0.0);
+    CGAssociateMouseAndMouseCursorPosition (0);
     CGWarpMouseCursorPosition (cgp);
-    CFRelease(evsrc);
+    if (grab_state != QZ_INVISIBLE_GRAB) { /* can't leave it disassociated? */
+        CGAssociateMouseAndMouseCursorPosition (1);
+    }
     SDL_PrivateAppActive (QZ_IsMouseInWindow (this), SDL_APPMOUSEFOCUS);
 }