summaryrefslogtreecommitdiff
path: root/platform/osx/os_osx.mm
diff options
context:
space:
mode:
authorCarl Olsson <carl.olsson@gmail.com>2015-02-15 18:21:35 +1000
committerCarl Olsson <carl.olsson@gmail.com>2015-02-15 18:21:35 +1000
commit196185d0be3ea7c05335c03d7e2db3e7c17d7a49 (patch)
tree572596c4261ed5e520ba1628661261ea0d5ee620 /platform/osx/os_osx.mm
parent6a38ab1b43e4a107a28c52ba2036a4886794f625 (diff)
parent2185c018f6593e6d64b2beb62202d2291e2e008e (diff)
Merge branch 'master' of https://github.com/okamstudio/godot
Conflicts: scene/2d/tile_map.cpp
Diffstat (limited to 'platform/osx/os_osx.mm')
-rw-r--r--platform/osx/os_osx.mm13
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);