diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2021-11-11 14:02:08 +0200 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2021-11-11 14:02:08 +0200 |
commit | f6e449a194c09e13e7845c84a156f45bb1f202c8 (patch) | |
tree | 2c9718cf81e79e41298592020849c754f767ef78 /platform/osx | |
parent | 171a69757f575bbc55c686956097c7b4434ec1f8 (diff) |
Make window unmovable by dragging title bar, when mouse in captured or confined mode.
Diffstat (limited to 'platform/osx')
-rw-r--r-- | platform/osx/display_server_osx.mm | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/platform/osx/display_server_osx.mm b/platform/osx/display_server_osx.mm index 03301af0af..647f501e6b 100644 --- a/platform/osx/display_server_osx.mm +++ b/platform/osx/display_server_osx.mm @@ -1920,6 +1920,7 @@ void DisplayServerOSX::mouse_set_mode(MouseMode p_mode) { return; } + WindowData &wd = windows[MAIN_WINDOW_ID]; if (p_mode == MOUSE_MODE_CAPTURED) { // Apple Docs state that the display parameter is not used. // "This parameter is not used. By default, you may pass kCGDirectMainDisplay." @@ -1928,7 +1929,7 @@ void DisplayServerOSX::mouse_set_mode(MouseMode p_mode) { CGDisplayHideCursor(kCGDirectMainDisplay); } CGAssociateMouseAndMouseCursorPosition(false); - WindowData &wd = windows[MAIN_WINDOW_ID]; + [wd.window_object setMovable:NO]; 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; @@ -1938,17 +1939,21 @@ void DisplayServerOSX::mouse_set_mode(MouseMode p_mode) { if (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED) { CGDisplayHideCursor(kCGDirectMainDisplay); } + [wd.window_object setMovable:YES]; CGAssociateMouseAndMouseCursorPosition(true); } else if (p_mode == MOUSE_MODE_CONFINED) { CGDisplayShowCursor(kCGDirectMainDisplay); + [wd.window_object setMovable:NO]; CGAssociateMouseAndMouseCursorPosition(false); } else if (p_mode == MOUSE_MODE_CONFINED_HIDDEN) { if (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED) { CGDisplayHideCursor(kCGDirectMainDisplay); } + [wd.window_object setMovable:NO]; CGAssociateMouseAndMouseCursorPosition(false); } else { // MOUSE_MODE_VISIBLE CGDisplayShowCursor(kCGDirectMainDisplay); + [wd.window_object setMovable:YES]; CGAssociateMouseAndMouseCursorPosition(true); } |