diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2017-08-04 23:40:03 +0300 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2017-08-04 23:43:32 +0300 |
commit | 0ed3da8e2a4b797db6cd3edf5949fff992b6bc0b (patch) | |
tree | b9453b3de00112285c9c90340f9b5c03208bb8be /platform/osx | |
parent | f79a5c464b95bdd274a4e9e5ff4713c7de2be011 (diff) |
Fix warp_mouse_pos on macOS
Diffstat (limited to 'platform/osx')
-rw-r--r-- | platform/osx/os_osx.mm | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 4a01532d89..19224199d1 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); |