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

Commit

Permalink
Mac: Don't supress mousemoves after warp.
Browse files Browse the repository at this point in the history
By default, synthesizing events supresses real events for a quarter
second. This makes for some wonky behavior.
  • Loading branch information
jorgenpt committed Apr 26, 2013
1 parent 499beb1 commit 131844f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
7 changes: 7 additions & 0 deletions src/video/cocoa/SDL_cocoamouse.m
Expand Up @@ -192,7 +192,14 @@

point.x = (float)window->x + x;
point.y = (float)window->y + y;

/* According to the docs, this was deprecated in 10.6, but it's still
* around. The substitute requires a CGEventSource, but I'm not entirely
* sure how we'd procure the right one for this event.
*/
CGSetLocalEventsSuppressionInterval(0.0);
CGWarpMouseCursorPosition(point);
CGSetLocalEventsSuppressionInterval(0.25);

/* CGWarpMouseCursorPosition doesn't generate a window event, unlike our
* other implementations' APIs.
Expand Down
10 changes: 5 additions & 5 deletions src/video/cocoa/SDL_cocoawindow.m
Expand Up @@ -393,13 +393,13 @@ - (void)mouseMoved:(NSEvent *)theEvent
cgpoint.x = window->x + x;
cgpoint.y = window->y + y;

/* We have to disassociate the curosr & the mouse before issuing
* this cursor warp, otherwise it gets limited to one update per
* 250ms, and looks very choppy.
/* According to the docs, this was deprecated in 10.6, but it's still
* around. The substitute requires a CGEventSource, but I'm not entirely
* sure how we'd procure the right one for this event.
*/
CGAssociateMouseAndMouseCursorPosition(NO);
CGSetLocalEventsSuppressionInterval(0.0);
CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, cgpoint);
CGAssociateMouseAndMouseCursorPosition(YES);
CGSetLocalEventsSuppressionInterval(0.25);
}
}
SDL_SendMouseMotion(window, 0, 0, x, y);
Expand Down

0 comments on commit 131844f

Please sign in to comment.