src/events/SDL_mouse.c
changeset 7089 257fc4e541e1
parent 7037 3fedf1f25b94
child 7097 84bbd421d62f
     1.1 --- a/src/events/SDL_mouse.c	Mon Apr 22 18:14:32 2013 -0700
     1.2 +++ b/src/events/SDL_mouse.c	Mon Apr 22 18:14:55 2013 -0700
     1.3 @@ -33,6 +33,8 @@
     1.4  /* The mouse state */
     1.5  static SDL_Mouse SDL_mouse;
     1.6  
     1.7 +static int
     1.8 +SDL_PrivateSendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relative, int x, int y);
     1.9  
    1.10  /* Public functions */
    1.11  int
    1.12 @@ -154,8 +156,9 @@
    1.13  #endif
    1.14          if (window == mouse->focus) {
    1.15  #ifdef DEBUG_MOUSE
    1.16 -            printf("Mouse left window, synthesizing focus lost event\n");
    1.17 +            printf("Mouse left window, synthesizing move & focus lost event\n");
    1.18  #endif
    1.19 +            SDL_PrivateSendMouseMotion(window, mouse->mouseID, 0, x, y);
    1.20              SDL_SetMouseFocus(NULL);
    1.21          }
    1.22          return SDL_FALSE;
    1.23 @@ -176,18 +179,25 @@
    1.24  int
    1.25  SDL_SendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relative, int x, int y)
    1.26  {
    1.27 +    if (window && !relative) {
    1.28 +        SDL_Mouse *mouse = SDL_GetMouse();
    1.29 +        if (!SDL_UpdateMouseFocus(window, x, y, mouse->buttonstate)) {
    1.30 +            return 0;
    1.31 +        }
    1.32 +    }
    1.33 +
    1.34 +    return SDL_PrivateSendMouseMotion(window, mouseID, relative, x, y);
    1.35 +}
    1.36 +
    1.37 +static int
    1.38 +SDL_PrivateSendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relative, int x, int y)
    1.39 +{
    1.40      SDL_Mouse *mouse = SDL_GetMouse();
    1.41      int posted;
    1.42      int xrel;
    1.43      int yrel;
    1.44      int x_max = 0, y_max = 0;
    1.45  
    1.46 -    if (window && !relative) {
    1.47 -        if (!SDL_UpdateMouseFocus(window, x, y, mouse->buttonstate)) {
    1.48 -            return 0;
    1.49 -        }
    1.50 -    }
    1.51 -
    1.52      /* relative motion is calculated regarding the system cursor last position */
    1.53      if (relative) {
    1.54          xrel = x;
    1.55 @@ -676,4 +686,4 @@
    1.56      return shown;
    1.57  }
    1.58  
    1.59 -/* vi: set ts=4 sw=4 expandtab: */
    1.60 +/* vi: set ts=4 sw=4 expandtab: */
    1.61 \ No newline at end of file