x11: make last mouse coords sane upon window entry (thanks, Cengiz!).
authorRyan C. Gordon <icculus@icculus.org>
Thu, 07 Jan 2016 19:58:00 -0500
changeset 10045 e1f07cbb3c86
parent 10044 8fc20bbbed5c
child 10046 4b62fb588d22
x11: make last mouse coords sane upon window entry (thanks, Cengiz!). (and thanks to Cengiz for many of the previous Unreal-related patches! They were generically credited to Epic Games, but a large amount of that work was his contribution.) Fixes Bugzilla #3067.
src/video/x11/SDL_x11events.c
--- a/src/video/x11/SDL_x11events.c	Thu Jan 07 17:21:50 2016 -0800
+++ b/src/video/x11/SDL_x11events.c	Thu Jan 07 19:58:00 2016 -0500
@@ -636,6 +636,7 @@
 
         /* Gaining mouse coverage? */
     case EnterNotify:{
+            SDL_Mouse *mouse = SDL_GetMouse();
 #ifdef DEBUG_XEVENTS
             printf("window %p: EnterNotify! (%d,%d,%d)\n", data,
                    xevent.xcrossing.x,
@@ -648,7 +649,10 @@
 #endif
             SDL_SetMouseFocus(data->window);
 
-            if (!SDL_GetMouse()->relative_mode) {
+            mouse->last_x = xevent.xcrossing.x;
+            mouse->last_y = xevent.xcrossing.y;
+
+            if (!mouse->relative_mode) {
                 SDL_SendMouseMotion(data->window, 0, 0, xevent.xcrossing.x, xevent.xcrossing.y);
             }
         }