summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-08-07 14:47:54 +0200
committerGitHub <noreply@github.com>2017-08-07 14:47:54 +0200
commitae88eb5b5061f83cc6e6fd649c36bb7cef3e8ea8 (patch)
treedf9884d0db0eaf7401f17196147cd691db0e0926
parentb31ba2f187679b1cdc10fd31a48e59177a5cb0cc (diff)
parent0ed3da8e2a4b797db6cd3edf5949fff992b6bc0b (diff)
Merge pull request #10099 from bruvzg/3.0-fix-osx-warp_mouse_pos
Fix warp_mouse_pos on macOS
-rw-r--r--platform/osx/os_osx.mm11
1 files changed, 3 insertions, 8 deletions
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index cfa039c130..b45647b8bb 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -1081,18 +1081,13 @@ void OS_OSX::warp_mouse_pos(const Point2 &p_to) {
mouse_y = p_to.y;
} else { //set OS position
- /* 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];
- NSRect pointInWindowRect;
- pointInWindowRect.origin = pointInWindow;
+ const NSRect contentRect = [window_view frame];
+ NSRect pointInWindowRect = NSMakeRect(p_to.x / display_scale, contentRect.size.height - (p_to.y / display_scale) - 1, 0, 0);
NSPoint pointOnScreen = [[window_view window] convertRectToScreen:pointInWindowRect].origin;
//point in scren coords
- CGPoint lMouseWarpPos = { pointOnScreen.x, pointOnScreen.y };
+ CGPoint lMouseWarpPos = { pointOnScreen.x, CGDisplayBounds(CGMainDisplayID()).size.height - pointOnScreen.y };
//do the warping
CGEventSourceRef lEventRef = CGEventSourceCreate(kCGEventSourceStateCombinedSessionState);