Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Make sure to send MOUSEMOTION on window enter.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jorgenpt committed Apr 24, 2013
1 parent 6c5f798 commit 8e89a32
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/events/SDL_mouse.c
Expand Up @@ -165,13 +165,11 @@ SDL_UpdateMouseFocus(SDL_Window * window, int x, int y, Uint32 buttonstate)
}

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;
}
Expand Down Expand Up @@ -686,4 +684,4 @@ SDL_ShowCursor(int toggle)
return shown;
}

/* vi: set ts=4 sw=4 expandtab: */
/* vi: set ts=4 sw=4 expandtab: */
4 changes: 4 additions & 0 deletions src/video/x11/SDL_x11events.c
Expand Up @@ -310,6 +310,10 @@ X11_DispatchEvent(_THIS)
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? */
Expand Down

0 comments on commit 8e89a32

Please sign in to comment.