src/video/SDL_video.c
changeset 7107 2fcf7bf1d2b2
parent 7091 ff07fad908f8
child 7112 a1a723edea64
     1.1 --- a/src/video/SDL_video.c	Wed Apr 24 12:20:48 2013 -0700
     1.2 +++ b/src/video/SDL_video.c	Wed Apr 24 12:20:51 2013 -0700
     1.3 @@ -2044,10 +2044,17 @@
     1.4  void
     1.5  SDL_OnWindowFocusGained(SDL_Window * window)
     1.6  {
     1.7 +    SDL_Mouse *mouse = SDL_GetMouse();
     1.8 +
     1.9      if (window->gamma && _this->SetWindowGammaRamp) {
    1.10          _this->SetWindowGammaRamp(_this, window, window->gamma);
    1.11      }
    1.12  
    1.13 +    if (mouse && mouse->relative_mode) {
    1.14 +        SDL_SetMouseFocus(window);
    1.15 +        SDL_WarpMouseInWindow(window, window->w/2, window->h/2);
    1.16 +    }
    1.17 +
    1.18      SDL_UpdateWindowGrab(window);
    1.19  }
    1.20  
    1.21 @@ -2067,10 +2074,17 @@
    1.22  void
    1.23  SDL_OnWindowFocusLost(SDL_Window * window)
    1.24  {
    1.25 +    SDL_Mouse *mouse = SDL_GetMouse();
    1.26 +
    1.27      if (window->gamma && _this->SetWindowGammaRamp) {
    1.28          _this->SetWindowGammaRamp(_this, window, window->saved_gamma);
    1.29      }
    1.30  
    1.31 +    if (mouse && mouse->relative_mode) {
    1.32 +        /* Restore the expected mouse position */
    1.33 +        SDL_WarpMouseInWindow(window, mouse->original_x, mouse->original_y);
    1.34 +    }
    1.35 +
    1.36      SDL_UpdateWindowGrab(window);
    1.37  
    1.38      /* If we're fullscreen on a single-head system and lose focus, minimize */