Send mouse leave updates for Windows and X11.
We now generate a final SDL_MOUSEMOTION before the cursor leaves the window, followed by a SDL_WINDOWEVENT_LEAVE.
This commit is contained in:
parent
c7fb60a46b
commit
f7032de060
9 changed files with 69 additions and 10 deletions
|
@ -33,6 +33,8 @@
|
|||
/* The mouse state */
|
||||
static SDL_Mouse SDL_mouse;
|
||||
|
||||
static int
|
||||
SDL_PrivateSendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relative, int x, int y);
|
||||
|
||||
/* Public functions */
|
||||
int
|
||||
|
@ -154,8 +156,9 @@ SDL_UpdateMouseFocus(SDL_Window * window, int x, int y, Uint32 buttonstate)
|
|||
#endif
|
||||
if (window == mouse->focus) {
|
||||
#ifdef DEBUG_MOUSE
|
||||
printf("Mouse left window, synthesizing focus lost event\n");
|
||||
printf("Mouse left window, synthesizing move & focus lost event\n");
|
||||
#endif
|
||||
SDL_PrivateSendMouseMotion(window, mouse->mouseID, 0, x, y);
|
||||
SDL_SetMouseFocus(NULL);
|
||||
}
|
||||
return SDL_FALSE;
|
||||
|
@ -175,6 +178,19 @@ SDL_UpdateMouseFocus(SDL_Window * window, int x, int y, Uint32 buttonstate)
|
|||
|
||||
int
|
||||
SDL_SendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relative, int x, int y)
|
||||
{
|
||||
if (window && !relative) {
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
if (!SDL_UpdateMouseFocus(window, x, y, mouse->buttonstate)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return SDL_PrivateSendMouseMotion(window, mouseID, relative, x, y);
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_PrivateSendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relative, int x, int y)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
int posted;
|
||||
|
@ -182,12 +198,6 @@ SDL_SendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relative, int
|
|||
int yrel;
|
||||
int x_max = 0, y_max = 0;
|
||||
|
||||
if (window && !relative) {
|
||||
if (!SDL_UpdateMouseFocus(window, x, y, mouse->buttonstate)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* relative motion is calculated regarding the system cursor last position */
|
||||
if (relative) {
|
||||
xrel = x;
|
||||
|
@ -676,4 +686,4 @@ SDL_ShowCursor(int toggle)
|
|||
return shown;
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -148,12 +148,14 @@ SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1,
|
|||
return 0;
|
||||
}
|
||||
window->flags |= SDL_WINDOW_MOUSE_FOCUS;
|
||||
SDL_OnWindowEnter(window);
|
||||
break;
|
||||
case SDL_WINDOWEVENT_LEAVE:
|
||||
if (!(window->flags & SDL_WINDOW_MOUSE_FOCUS)) {
|
||||
return 0;
|
||||
}
|
||||
window->flags &= ~SDL_WINDOW_MOUSE_FOCUS;
|
||||
SDL_OnWindowLeave(window);
|
||||
break;
|
||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||
if (window->flags & SDL_WINDOW_INPUT_FOCUS) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue