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 10045e1f07cbb3c86
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
     1.1 --- a/src/video/x11/SDL_x11events.c	Thu Jan 07 17:21:50 2016 -0800
     1.2 +++ b/src/video/x11/SDL_x11events.c	Thu Jan 07 19:58:00 2016 -0500
     1.3 @@ -636,6 +636,7 @@
     1.4  
     1.5          /* Gaining mouse coverage? */
     1.6      case EnterNotify:{
     1.7 +            SDL_Mouse *mouse = SDL_GetMouse();
     1.8  #ifdef DEBUG_XEVENTS
     1.9              printf("window %p: EnterNotify! (%d,%d,%d)\n", data,
    1.10                     xevent.xcrossing.x,
    1.11 @@ -648,7 +649,10 @@
    1.12  #endif
    1.13              SDL_SetMouseFocus(data->window);
    1.14  
    1.15 -            if (!SDL_GetMouse()->relative_mode) {
    1.16 +            mouse->last_x = xevent.xcrossing.x;
    1.17 +            mouse->last_y = xevent.xcrossing.y;
    1.18 +
    1.19 +            if (!mouse->relative_mode) {
    1.20                  SDL_SendMouseMotion(data->window, 0, 0, xevent.xcrossing.x, xevent.xcrossing.y);
    1.21              }
    1.22          }