|
|
@ -1158,25 +1158,22 @@ void _glfwPlatformWaitEvents( void ) |
|
|
|
|
|
|
|
|
|
|
|
void _glfwPlatformSetCursorPos(_GLFWwindow* window, int x, int y) |
|
|
|
void _glfwPlatformSetCursorPos(_GLFWwindow* window, int x, int y) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// The library seems to assume that after calling this the cursor won't move, |
|
|
|
if (window->mode == GLFW_FULLSCREEN) |
|
|
|
// but obviously it will, and escape the app's window, and activate other apps, |
|
|
|
{ |
|
|
|
// and other badness in pain. I think the API's just silly, but maybe I'm |
|
|
|
NSPoint globalPoint = NSMakePoint(x, y); |
|
|
|
// misunderstanding it... |
|
|
|
CGDisplayMoveCursorToPoint(CGMainDisplayID(), globalPoint); |
|
|
|
|
|
|
|
} |
|
|
|
// Also, (x, y) are window coords... |
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
// Also, it doesn't seem possible to write this robustly without |
|
|
|
NSPoint localPoint = NSMakePoint(x, window->height - y - 1); |
|
|
|
// calculating the maximum y coordinate of all screens, since Cocoa's |
|
|
|
NSPoint globalPoint = [window->NS.object convertBaseToScreen:localPoint]; |
|
|
|
// "global coordinates" are upside down from CG's... |
|
|
|
CGPoint mainScreenOrigin = CGDisplayBounds(CGMainDisplayID()).origin; |
|
|
|
|
|
|
|
double mainScreenHeight = CGDisplayBounds(CGMainDisplayID()).size.height; |
|
|
|
NSPoint localPoint = NSMakePoint(x, window->height - y - 1); |
|
|
|
CGPoint targetPoint = CGPointMake(globalPoint.x - mainScreenOrigin.x, |
|
|
|
NSPoint globalPoint = [window->NS.object convertBaseToScreen:localPoint]; |
|
|
|
mainScreenHeight - globalPoint.y - |
|
|
|
CGPoint mainScreenOrigin = CGDisplayBounds(CGMainDisplayID()).origin; |
|
|
|
mainScreenOrigin.y); |
|
|
|
double mainScreenHeight = CGDisplayBounds(CGMainDisplayID()).size.height; |
|
|
|
CGDisplayMoveCursorToPoint(CGMainDisplayID(), targetPoint); |
|
|
|
CGPoint targetPoint = CGPointMake(globalPoint.x - mainScreenOrigin.x, |
|
|
|
} |
|
|
|
mainScreenHeight - globalPoint.y - |
|
|
|
|
|
|
|
mainScreenOrigin.y); |
|
|
|
|
|
|
|
CGDisplayMoveCursorToPoint(CGMainDisplayID(), targetPoint); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|