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

--HG--
extra : histedit_source : e89e8952efcc07da98a306757edeaeded31517a9
This commit is contained in:
Jørgen P. Tjernø 2013-04-23 18:47:32 -07:00
parent 4b4bea7294
commit 694ebd59a3
2 changed files with 8 additions and 6 deletions

View file

@ -165,13 +165,11 @@ SDL_UpdateMouseFocus(SDL_Window * window, int x, int y, Uint32 buttonstate)
} }
if (window != mouse->focus) { if (window != mouse->focus) {
mouse->last_x = x;
mouse->last_y = y;
#ifdef DEBUG_MOUSE #ifdef DEBUG_MOUSE
printf("Mouse entered window, synthesizing focus gain event\n"); printf("Mouse entered window, synthesizing focus gain & move event\n");
#endif #endif
SDL_SetMouseFocus(window); SDL_SetMouseFocus(window);
SDL_PrivateSendMouseMotion(window, mouse->mouseID, 0, x, y);
} }
return SDL_TRUE; return SDL_TRUE;
} }
@ -686,4 +684,4 @@ SDL_ShowCursor(int toggle)
return shown; return shown;
} }
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */

View file

@ -310,6 +310,10 @@ X11_DispatchEvent(_THIS)
printf("Mode: NotifyUngrab\n"); printf("Mode: NotifyUngrab\n");
#endif #endif
SDL_SetMouseFocus(data->window); SDL_SetMouseFocus(data->window);
if (!SDL_GetMouse()->relative_mode) {
SDL_SendMouseMotion(data->window, 0, 0, xevent.xcrossing.x, xevent.xcrossing.y);
}
} }
break; break;
/* Losing mouse coverage? */ /* Losing mouse coverage? */