diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-02-14 19:22:06 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-02-14 19:22:06 -0300 |
commit | d2f86cc09bf4136ebc1c2bbb8ec7b48a439c0371 (patch) | |
tree | 5f9c5ffe7aec749a3d4732036f9a506d01932aa7 /platform/osx | |
parent | a49802ae332e34542c0f835cce74fb3d5e49675a (diff) |
fixes to mouse warp
-can warp now from viewport and control, in their respective coordinate
systems
-warp is now local to the window on Windows and OSX.
IF YOU RUN OSX, PLEASE TEST THIS! And make sure it works!, new code is
in OS_OSX::warp_mouse_pos. I don't have OSX so i can't test!
Diffstat (limited to 'platform/osx')
-rw-r--r-- | platform/osx/os_osx.mm | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 5bc47a74c1..af2552496b 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -1093,8 +1093,19 @@ void OS_OSX::warp_mouse_pos(const Point2& p_to) { mouse_y = p_to.y; } else{ //set OS position - CGPoint lMouseWarpPos = {p_to.x, p_to.y}; + /* this code has not been tested, please be a kind soul and fix it if it fails! */ + + //local point in window coords + NSPoint localPoint = { p_to.x, p_to.y }; + + NSPoint pointInWindow = [window_view convertPoint:localPoint toView:nil]; + NSPoint pointOnScreen = [[window_view window] convertRectToScreen:(CGRect){.origin=pointInWindow}]; + + //point in scren coords + CGPoint lMouseWarpPos = { pointOnScreen.x, pointOnScreen.y}; + + //do the warping CGEventSourceRef lEventRef = CGEventSourceCreate(kCGEventSourceStateCombinedSessionState); CGEventSourceSetLocalEventsSuppressionInterval(lEventRef, 0.0); CGAssociateMouseAndMouseCursorPosition(false); |