Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Mac: Fix incorrect relative jump on focus / start.

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 10f4e6fec67542ac01c8f2364e7c3db05f0831a6
Showing with 8 additions and 5 deletions.
  1. +6 −4 src/video/cocoa/SDL_cocoamouse.m
  2. +2 −1 src/video/cocoa/SDL_cocoawindow.m
@@ -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
@@ -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;

0 comments on commit 10f4e6f

Please sign in to comment.