Make sure to send MOUSEMOTION on window enter.
authorJørgen P. Tjernø <jorgen@valvesoftware.com>
Tue, 23 Apr 2013 18:47:32 -0700
changeset 7097 84bbd421d62f
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
--- a/src/events/SDL_mouse.c	Tue Apr 23 16:54:52 2013 -0300
+++ b/src/events/SDL_mouse.c	Tue Apr 23 18:47:32 2013 -0700
@@ -165,13 +165,11 @@
     }
 
     if (window != mouse->focus) {
-        mouse->last_x = x;
-        mouse->last_y = y;
-
 #ifdef DEBUG_MOUSE
-        printf("Mouse entered window, synthesizing focus gain event\n");
+         printf("Mouse entered window, synthesizing focus gain & move event\n");
 #endif
-        SDL_SetMouseFocus(window);
+         SDL_SetMouseFocus(window);
+         SDL_PrivateSendMouseMotion(window, mouse->mouseID, 0, x, y);
     }
     return SDL_TRUE;
 }
@@ -686,4 +684,4 @@
     return shown;
 }
 
-/* vi: set ts=4 sw=4 expandtab: */
\ No newline at end of file
+/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/x11/SDL_x11events.c	Tue Apr 23 16:54:52 2013 -0300
+++ b/src/video/x11/SDL_x11events.c	Tue Apr 23 18:47:32 2013 -0700
@@ -310,6 +310,10 @@
                 printf("Mode: NotifyUngrab\n");
 #endif
             SDL_SetMouseFocus(data->window);
+
+            if (!SDL_GetMouse()->relative_mode) {
+                SDL_SendMouseMotion(data->window, 0, 0, xevent.xcrossing.x, xevent.xcrossing.y);
+            }
         }
         break;
         /* Losing mouse coverage? */