Skip to content

Commit

Permalink
Merge pull request #40379 from bruvzg/macos_11_window_size
Browse files Browse the repository at this point in the history
[macOS] Fix window size on macOS Big Sur, use top-left corner as resize origin.
  • Loading branch information
akien-mga authored Jul 14, 2020
2 parents e387278 + 850bbab commit 28d83ec
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions platform/osx/display_server_osx.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2583,16 +2583,18 @@ static void displays_arrangement_changed(CGDirectDisplayID display_id, CGDisplay

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);
}
Expand Down

0 comments on commit 28d83ec

Please sign in to comment.