diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-09-28 10:08:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-28 10:08:05 +0200 |
commit | 0ba4a8ba7b0f54ac146bab3942bdd9ea60b8e18d (patch) | |
tree | 6b1d83181ccf74d2baa2b53da1b0709f5736a78f | |
parent | 82d1265185d27a7520167b1dd3955787bcc35bb1 (diff) | |
parent | f4a2eabf42ee3c7eae76f616646beb5c27ee82b1 (diff) |
Merge pull request #42327 from bruvzg/4_mac_captured_fix
[macOS] Fix mouse position in captured mode.
-rw-r--r-- | platform/osx/display_server_osx.mm | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/platform/osx/display_server_osx.mm b/platform/osx/display_server_osx.mm index e33af520c9..49f0e7bfa3 100644 --- a/platform/osx/display_server_osx.mm +++ b/platform/osx/display_server_osx.mm @@ -2041,6 +2041,12 @@ void DisplayServerOSX::mouse_set_mode(MouseMode p_mode) { CGDisplayHideCursor(kCGDirectMainDisplay); } CGAssociateMouseAndMouseCursorPosition(false); + WindowData &wd = windows[MAIN_WINDOW_ID]; + const NSRect contentRect = [wd.window_view frame]; + NSRect pointInWindowRect = NSMakeRect(contentRect.size.width / 2, contentRect.size.height / 2, 0, 0); + NSPoint pointOnScreen = [[wd.window_view window] convertRectToScreen:pointInWindowRect].origin; + CGPoint lMouseWarpPos = { pointOnScreen.x, CGDisplayBounds(CGMainDisplayID()).size.height - pointOnScreen.y }; + CGWarpMouseCursorPosition(lMouseWarpPos); } else if (p_mode == MOUSE_MODE_HIDDEN) { if (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED) { CGDisplayHideCursor(kCGDirectMainDisplay); |