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

Commit

Permalink
Mac: Fix incorrect relative jump on focus / start.
Browse files Browse the repository at this point in the history
We should no longer send huge jumps on relative mode focus changes if
the cursor was moved around, or on initial start.

Fixes http://bugzilla.libsdl.org/show_bug.cgi?id=1836
  • Loading branch information
jorgenpt committed Jun 4, 2013
1 parent d3c1882 commit 10f4e6f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/video/cocoa/SDL_cocoamouse.m
Expand Up @@ -224,10 +224,12 @@ + (NSCursor *)invisibleCursor
CGWarpMouseCursorPosition(point);
CGSetLocalEventsSuppressionInterval(0.25);

/* CGWarpMouseCursorPosition doesn't generate a window event, unlike our
* other implementations' APIs.
*/
SDL_SendMouseMotion(mouse->focus, mouse->mouseID, 0, x, y);
if (!mouse->relative_mode) {
/* CGWarpMouseCursorPosition doesn't generate a window event, unlike our
* other implementations' APIs.
*/
SDL_SendMouseMotion(mouse->focus, mouse->mouseID, 0, x, y);
}
}

static int
Expand Down
3 changes: 2 additions & 1 deletion src/video/cocoa/SDL_cocoawindow.m
Expand Up @@ -240,12 +240,13 @@ - (void)windowDidDeminiaturize:(NSNotification *)aNotification
- (void)windowDidBecomeKey:(NSNotification *)aNotification
{
SDL_Window *window = _data->window;
SDL_Mouse *mouse = SDL_GetMouse();

/* We're going to get keyboard events, since we're key. */
SDL_SetKeyboardFocus(window);

/* If we just gained focus we need the updated mouse position */
{
if (!mouse->relative_mode) {
NSPoint point;
int x, y;

Expand Down

0 comments on commit 10f4e6f

Please sign in to comment.