src/events/SDL_mouse.c
changeset 6302 b0ae93a5b8d6
parent 6301 e8a69c5378e7
child 6666 018f8019ce36
--- a/src/events/SDL_mouse.c	Fri Feb 03 23:53:51 2012 +1300
+++ b/src/events/SDL_mouse.c	Sat Feb 04 00:13:21 2012 +1300
@@ -323,9 +323,13 @@
     /* Set the relative mode */
     mouse->relative_mode = enabled;
 
-    if (!enabled && mouse->focus) {
+    if (enabled) {
+        /* Save the expected mouse position */
+        mouse->original_x = mouse->x;
+        mouse->original_y = mouse->y;
+    } else if (mouse->focus) {
         /* Restore the expected mouse position */
-        SDL_WarpMouseInWindow(mouse->focus, mouse->x, mouse->y);
+        SDL_WarpMouseInWindow(mouse->focus, mouse->original_x, mouse->original_y);
     }
 
     /* Flush pending mouse motion */