src/events/SDL_mouse.c
changeset 4484 9322f7db8603
parent 4465 3e69e077cb95
child 5262 b530ef003506
     1.1 --- a/src/events/SDL_mouse.c	Mon Jul 05 22:45:45 2010 -0700
     1.2 +++ b/src/events/SDL_mouse.c	Mon Jul 05 22:48:13 2010 -0700
     1.3 @@ -112,7 +112,7 @@
     1.4  }
     1.5  
     1.6  int
     1.7 -SDL_SendMouseMotion(int relative, int x, int y)
     1.8 +SDL_SendMouseMotion(SDL_Window * window, int relative, int x, int y)
     1.9  {
    1.10      SDL_Mouse *mouse = &SDL_mouse;
    1.11      int posted;
    1.12 @@ -120,6 +120,10 @@
    1.13      int yrel;
    1.14      int x_max = 0, y_max = 0;
    1.15  
    1.16 +    if (window) {
    1.17 +        SDL_SetMouseFocus(window);
    1.18 +    }
    1.19 +
    1.20      /* the relative motion is calculated regarding the system cursor last position */
    1.21      if (relative) {
    1.22          xrel = x;
    1.23 @@ -194,12 +198,16 @@
    1.24  }
    1.25  
    1.26  int
    1.27 -SDL_SendMouseButton(Uint8 state, Uint8 button)
    1.28 +SDL_SendMouseButton(SDL_Window * window, Uint8 state, Uint8 button)
    1.29  {
    1.30      SDL_Mouse *mouse = &SDL_mouse;
    1.31      int posted;
    1.32      Uint32 type;
    1.33  
    1.34 +    if (window) {
    1.35 +        SDL_SetMouseFocus(window);
    1.36 +    }
    1.37 +
    1.38      /* Figure out which event to perform */
    1.39      switch (state) {
    1.40      case SDL_PRESSED:
    1.41 @@ -239,11 +247,15 @@
    1.42  }
    1.43  
    1.44  int
    1.45 -SDL_SendMouseWheel(int x, int y)
    1.46 +SDL_SendMouseWheel(SDL_Window * window, int x, int y)
    1.47  {
    1.48      SDL_Mouse *mouse = &SDL_mouse;
    1.49      int posted;
    1.50  
    1.51 +    if (window) {
    1.52 +        SDL_SetMouseFocus(window);
    1.53 +    }
    1.54 +
    1.55      if (!x && !y) {
    1.56          return 0;
    1.57      }
    1.58 @@ -304,8 +316,7 @@
    1.59      if (mouse->WarpMouse) {
    1.60          mouse->WarpMouse(mouse, window, x, y);
    1.61      } else {
    1.62 -        SDL_SetMouseFocus(window);
    1.63 -        SDL_SendMouseMotion(0, x, y);
    1.64 +        SDL_SendMouseMotion(window, 0, x, y);
    1.65      }
    1.66  }
    1.67