Merge pull request #40382 from bruvzg/macos_11_window_size_3

[macOS, 3.2] Fix window size on macOS Big Sur, use top-left corner as resize origin.
This commit is contained in:
Rémi Verschelde 2020-07-15 08:28:05 +02:00 committed by GitHub
commit e452c67476
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 13 deletions

View File

@ -2630,20 +2630,18 @@ void OS_OSX::set_window_size(const Size2 p_size) {
Size2 size = p_size / get_screen_max_scale(); Size2 size = p_size / get_screen_max_scale();
if (get_borderless_window() == false) { NSPoint top_left;
// NSRect used by setFrame includes the title bar, so add it to our size.y NSRect old_frame = [window_object frame];
CGFloat menuBarHeight = [[[NSApplication sharedApplication] mainMenu] menuBarHeight]; top_left.x = old_frame.origin.x;
if (menuBarHeight != 0.f) { top_left.y = NSMaxY(old_frame);
size.y += menuBarHeight;
} else {
if (floor(NSAppKitVersionNumber) < NSAppKitVersionNumber10_12) {
size.y += [[NSStatusBar systemStatusBar] thickness];
}
}
}
NSRect frame = [window_object frame]; NSRect new_frame = NSMakeRect(0, 0, size.x, size.y);
[window_object setFrame:NSMakeRect(frame.origin.x, frame.origin.y, size.x, size.y) display:YES]; new_frame = [window_object frameRectForContentRect:new_frame];
new_frame.origin.x = top_left.x;
new_frame.origin.y = top_left.y - new_frame.size.height;
[window_object setFrame:new_frame display:YES];
_update_window(); _update_window();
}; };