src/events/SDL_mouse.c
changeset 6302 b0ae93a5b8d6
parent 6301 e8a69c5378e7
child 6666 018f8019ce36
     1.1 --- a/src/events/SDL_mouse.c	Fri Feb 03 23:53:51 2012 +1300
     1.2 +++ b/src/events/SDL_mouse.c	Sat Feb 04 00:13:21 2012 +1300
     1.3 @@ -323,9 +323,13 @@
     1.4      /* Set the relative mode */
     1.5      mouse->relative_mode = enabled;
     1.6  
     1.7 -    if (!enabled && mouse->focus) {
     1.8 +    if (enabled) {
     1.9 +        /* Save the expected mouse position */
    1.10 +        mouse->original_x = mouse->x;
    1.11 +        mouse->original_y = mouse->y;
    1.12 +    } else if (mouse->focus) {
    1.13          /* Restore the expected mouse position */
    1.14 -        SDL_WarpMouseInWindow(mouse->focus, mouse->x, mouse->y);
    1.15 +        SDL_WarpMouseInWindow(mouse->focus, mouse->original_x, mouse->original_y);
    1.16      }
    1.17  
    1.18      /* Flush pending mouse motion */