Improved SetCursorPosition on Mac (fixes issue #46)

This commit is contained in:
Marco Antognini 2011-05-18 21:47:17 +02:00
parent 6383f0c800
commit c1ce16f4d6

View File

@ -281,9 +281,6 @@
{ {
if (myRequester == 0) return; if (myRequester == 0) return;
// Create a SFML event.
myRequester->MouseMovedAt(x, y);
// Flip for SFML window coordinate system // Flip for SFML window coordinate system
y = NSHeight([myWindow frame]) - y; y = NSHeight([myWindow frame]) - y;
@ -297,16 +294,15 @@
float const screenHeight = NSHeight([[myWindow screen] frame]); float const screenHeight = NSHeight([[myWindow screen] frame]);
screenCoord.y = screenHeight - screenCoord.y; screenCoord.y = screenHeight - screenCoord.y;
CGDirectDisplayID screenNumber = (CGDirectDisplayID)[[[[myWindow screen] deviceDescription] valueForKey:@"NSScreenNumber"] intValue];
// Place the cursor. // Place the cursor.
CGDisplayMoveCursorToPoint(screenNumber, CGPointMake(screenCoord.x, screenCoord.y)); CGEventRef event = CGEventCreateMouseEvent(NULL,
/* kCGEventMouseMoved,
CGDisplayMoveCursorToPoint -- Discussion : CGPointMake(screenCoord.x, screenCoord.y),
/*we don't care about this : */0);
No events are generated as a result of this move. CGEventPost(kCGHIDEventTap, event);
Points that lie outside the desktop are clipped to the desktop. CFRelease(event);
*/ // This is a workaround to deprecated CGSetLocalEventsSuppressionInterval.
// The event produced will be catched by SFML in sf::Window::FilterEvent.
} }