Mac: Fix incorrect relative jump on focus / start.
authorJørgen P. Tjernø <jorgen@valvesoftware.com>
Tue, 04 Jun 2013 14:54:49 -0700
changeset 7271 963d2ba35cfe
parent 7270 76df5476a6ce
child 7272 c502531983c7
Mac: Fix incorrect relative jump on focus / start. We should no longer send huge jumps on relative mode focus changes if the cursor was moved around, or on initial start. Fixes http://bugzilla.libsdl.org/show_bug.cgi?id=1836
src/video/cocoa/SDL_cocoamouse.m
src/video/cocoa/SDL_cocoawindow.m
--- a/src/video/cocoa/SDL_cocoamouse.m	Tue Jun 04 13:53:55 2013 -0700
+++ b/src/video/cocoa/SDL_cocoamouse.m	Tue Jun 04 14:54:49 2013 -0700
@@ -224,10 +224,12 @@
     CGWarpMouseCursorPosition(point);
     CGSetLocalEventsSuppressionInterval(0.25);
 
-    /* CGWarpMouseCursorPosition doesn't generate a window event, unlike our
-     * other implementations' APIs.
-     */
-    SDL_SendMouseMotion(mouse->focus, mouse->mouseID, 0, x, y);
+    if (!mouse->relative_mode) {
+        /* CGWarpMouseCursorPosition doesn't generate a window event, unlike our
+         * other implementations' APIs.
+         */
+        SDL_SendMouseMotion(mouse->focus, mouse->mouseID, 0, x, y);
+    }
 }
 
 static int
--- a/src/video/cocoa/SDL_cocoawindow.m	Tue Jun 04 13:53:55 2013 -0700
+++ b/src/video/cocoa/SDL_cocoawindow.m	Tue Jun 04 14:54:49 2013 -0700
@@ -240,12 +240,13 @@
 - (void)windowDidBecomeKey:(NSNotification *)aNotification
 {
     SDL_Window *window = _data->window;
+    SDL_Mouse *mouse = SDL_GetMouse();
 
     /* We're going to get keyboard events, since we're key. */
     SDL_SetKeyboardFocus(window);
 
     /* If we just gained focus we need the updated mouse position */
-    {
+    if (!mouse->relative_mode) {
         NSPoint point;
         int x, y;