src/events/SDL_mouse.c
changeset 5406 1517da4ab6b1
parent 5405 64fa8526e1ce
child 5473 5665ccbd6792
     1.1 --- a/src/events/SDL_mouse.c	Sun Feb 27 21:36:23 2011 -0800
     1.2 +++ b/src/events/SDL_mouse.c	Sun Feb 27 22:06:46 2011 -0800
     1.3 @@ -308,8 +308,18 @@
     1.4  {
     1.5      SDL_Mouse *mouse = SDL_GetMouse();
     1.6  
     1.7 -    /* Flush pending mouse motion */
     1.8 -    SDL_FlushEvent(SDL_MOUSEMOTION);
     1.9 +    if (enabled == mouse->relative_mode) {
    1.10 +        return 0;
    1.11 +    }
    1.12 +
    1.13 +    if (!mouse->SetRelativeMouseMode) {
    1.14 +        SDL_Unsupported();
    1.15 +        return -1;
    1.16 +    }
    1.17 +
    1.18 +    if (mouse->SetRelativeMouseMode(enabled) < 0) {
    1.19 +        return -1;
    1.20 +    }
    1.21  
    1.22      /* Set the relative mode */
    1.23      mouse->relative_mode = enabled;
    1.24 @@ -319,6 +329,9 @@
    1.25          SDL_WarpMouseInWindow(mouse->focus, mouse->x, mouse->y);
    1.26      }
    1.27  
    1.28 +    /* Flush pending mouse motion */
    1.29 +    SDL_FlushEvent(SDL_MOUSEMOTION);
    1.30 +
    1.31      /* Update cursor visibility */
    1.32      SDL_SetCursor(NULL);
    1.33