Make sure to send MOUSEMOTION on window enter.
authorJørgen P. Tjernø <jorgen@valvesoftware.com>
Tue, 23 Apr 2013 18:47:32 -0700
changeset 709784bbd421d62f
parent 7096 640f553441e4
child 7098 f4b2c6fb0258
Make sure to send MOUSEMOTION on window enter.

This should hopefully fix bug #1612. We now send mousemotion events when
the cursor enters the window as well as when it leaves.

Thanks to Alex Szpakowski for the fix.

Fixes http://bugzilla.libsdl.org/show_bug.cgi?id=1612
src/events/SDL_mouse.c
src/video/x11/SDL_x11events.c
     1.1 --- a/src/events/SDL_mouse.c	Tue Apr 23 16:54:52 2013 -0300
     1.2 +++ b/src/events/SDL_mouse.c	Tue Apr 23 18:47:32 2013 -0700
     1.3 @@ -165,13 +165,11 @@
     1.4      }
     1.5  
     1.6      if (window != mouse->focus) {
     1.7 -        mouse->last_x = x;
     1.8 -        mouse->last_y = y;
     1.9 -
    1.10  #ifdef DEBUG_MOUSE
    1.11 -        printf("Mouse entered window, synthesizing focus gain event\n");
    1.12 +         printf("Mouse entered window, synthesizing focus gain & move event\n");
    1.13  #endif
    1.14 -        SDL_SetMouseFocus(window);
    1.15 +         SDL_SetMouseFocus(window);
    1.16 +         SDL_PrivateSendMouseMotion(window, mouse->mouseID, 0, x, y);
    1.17      }
    1.18      return SDL_TRUE;
    1.19  }
    1.20 @@ -686,4 +684,4 @@
    1.21      return shown;
    1.22  }
    1.23  
    1.24 -/* vi: set ts=4 sw=4 expandtab: */
    1.25 \ No newline at end of file
    1.26 +/* vi: set ts=4 sw=4 expandtab: */
     2.1 --- a/src/video/x11/SDL_x11events.c	Tue Apr 23 16:54:52 2013 -0300
     2.2 +++ b/src/video/x11/SDL_x11events.c	Tue Apr 23 18:47:32 2013 -0700
     2.3 @@ -310,6 +310,10 @@
     2.4                  printf("Mode: NotifyUngrab\n");
     2.5  #endif
     2.6              SDL_SetMouseFocus(data->window);
     2.7 +
     2.8 +            if (!SDL_GetMouse()->relative_mode) {
     2.9 +                SDL_SendMouseMotion(data->window, 0, 0, xevent.xcrossing.x, xevent.xcrossing.y);
    2.10 +            }
    2.11          }
    2.12          break;
    2.13          /* Losing mouse coverage? */