Merge pull request #42328 from bruvzg/3_mac_captured_fix
[macOS, 3.2] Fix mouse position in captured mode.
This commit is contained in:
commit
ec01d6f25e
1 changed files with 6 additions and 0 deletions
|
@ -3174,6 +3174,12 @@ void OS_OSX::set_mouse_mode(MouseMode p_mode) {
|
|||
CGDisplayHideCursor(kCGDirectMainDisplay);
|
||||
}
|
||||
CGAssociateMouseAndMouseCursorPosition(false);
|
||||
|
||||
const NSRect contentRect = [window_view frame];
|
||||
NSRect pointInWindowRect = NSMakeRect(contentRect.size.width / 2, contentRect.size.height / 2, 0, 0);
|
||||
NSPoint pointOnScreen = [[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);
|
||||
|
|
Loading…
Reference in a new issue