diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-07-14 17:47:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-14 17:47:44 +0200 |
commit | 28d83ecf5ad000214a1875c5d30ff8da769db9e8 (patch) | |
tree | d11ad4540eb7b94046438093b393abb19d295f52 | |
parent | e387278b3bfb9c24a244a86f71483c4e40d521f1 (diff) | |
parent | 850bbabe56de8ce76b5237fb3dbec9788f5da5be (diff) |
Merge pull request #40379 from bruvzg/macos_11_window_size
[macOS] Fix window size on macOS Big Sur, use top-left corner as resize origin.
-rw-r--r-- | platform/osx/display_server_osx.mm | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/platform/osx/display_server_osx.mm b/platform/osx/display_server_osx.mm index 4793591b54..d7562a8860 100644 --- a/platform/osx/display_server_osx.mm +++ b/platform/osx/display_server_osx.mm @@ -2583,16 +2583,18 @@ void DisplayServerOSX::window_set_size(const Size2i p_size, WindowID p_window) { Size2i size = p_size / screen_get_max_scale(); - if (!wd.borderless) { - // NSRect used by setFrame includes the title bar, so add it to our size.y - CGFloat menuBarHeight = [[[NSApplication sharedApplication] mainMenu] menuBarHeight]; - if (menuBarHeight != 0.f) { - size.y += menuBarHeight; - } - } + NSPoint top_left; + NSRect old_frame = [wd.window_object frame]; + top_left.x = old_frame.origin.x; + top_left.y = NSMaxY(old_frame); - NSRect frame = [wd.window_object frame]; - [wd.window_object setFrame:NSMakeRect(frame.origin.x, frame.origin.y, size.x, size.y) display:YES]; + NSRect new_frame = NSMakeRect(0, 0, size.x, size.y); + new_frame = [wd.window_object frameRectForContentRect:new_frame]; + + new_frame.origin.x = top_left.x; + new_frame.origin.y = top_left.y - new_frame.size.height; + + [wd.window_object setFrame:new_frame display:YES]; _update_window(wd); } |