Skip to content

Commit 6d1c26a

Browse files
committed
macos: restore window size properly
1 parent 8d16395 commit 6d1c26a

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

ui/drivers/ui_cocoa.m

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -572,11 +572,11 @@ - (void)windowDidMove:(NSNotification *)notification
572572
if (!window_save_positions || is_fullscreen)
573573
return;
574574

575-
NSRect frame = self.window.frame;
576-
settings->uints.window_position_x = (unsigned)frame.origin.x;
577-
settings->uints.window_position_y = (unsigned)frame.origin.y;
578-
settings->uints.window_position_width = (unsigned)frame.size.width;
579-
settings->uints.window_position_height = (unsigned)frame.size.height;
575+
NSRect contentRect = [self.window contentRectForFrameRect:self.window.frame];
576+
settings->uints.window_position_x = (unsigned)contentRect.origin.x;
577+
settings->uints.window_position_y = (unsigned)contentRect.origin.y;
578+
settings->uints.window_position_width = (unsigned)contentRect.size.width;
579+
settings->uints.window_position_height = (unsigned)contentRect.size.height;
580580
}
581581

582582
- (void)windowDidResize:(NSNotification *)notification
@@ -589,11 +589,11 @@ - (void)windowDidResize:(NSNotification *)notification
589589
if (!window_save_positions || is_fullscreen)
590590
return;
591591

592-
NSRect frame = self.window.frame;
593-
settings->uints.window_position_x = (unsigned)frame.origin.x;
594-
settings->uints.window_position_y = (unsigned)frame.origin.y;
595-
settings->uints.window_position_width = (unsigned)frame.size.width;
596-
settings->uints.window_position_height = (unsigned)frame.size.height;
592+
NSRect contentRect = [self.window contentRectForFrameRect:self.window.frame];
593+
settings->uints.window_position_x = (unsigned)contentRect.origin.x;
594+
settings->uints.window_position_y = (unsigned)contentRect.origin.y;
595+
settings->uints.window_position_width = (unsigned)contentRect.size.width;
596+
settings->uints.window_position_height = (unsigned)contentRect.size.height;
597597
}
598598

599599
@end
@@ -778,11 +778,12 @@ - (void)updateWindowedSize:(gfx_ctx_mode_t)mode
778778

779779
if (window_save_positions)
780780
{
781-
NSRect frame;
782-
frame.origin.x = settings->uints.window_position_x;
783-
frame.origin.y = settings->uints.window_position_y;
784-
frame.size.width = settings->uints.window_position_width;
785-
frame.size.height = settings->uints.window_position_height;
781+
NSRect contentRect;
782+
contentRect.origin.x = settings->uints.window_position_x;
783+
contentRect.origin.y = settings->uints.window_position_y;
784+
contentRect.size.width = settings->uints.window_position_width;
785+
contentRect.size.height = settings->uints.window_position_height;
786+
NSRect frame = [self.window frameRectForContentRect:contentRect];
786787
[self.window setFrame:frame display:YES];
787788
}
788789
else

0 commit comments

Comments
 (0)