From c3d1e55397de7dc6530c5f5bb5f4175efc8de442 Mon Sep 17 00:00:00 2001 From: Nivaldo Date: Mon, 23 Nov 2026 14:07:13 -0300 Subject: [PATCH] native/macos: set_window_size sets the content size set_window_size passed the requested size to setFrame:, which includes the title bar, so the drawable area came out a title bar short. Convert it with frameRectForContentRect: first, so it means the content size as it does in Conf::window_width/window_height and on Windows and X11. The top edge still stays in place. Co-Authored-By: Claude Opus 5.5 --- src/native/macos.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/native/macos.rs b/src/native/macos.rs index b8d01fdef..e58207573 100644 --- a/src/native/macos.rs +++ b/src/native/macos.rs @@ -91,13 +91,20 @@ impl MacosDisplay { } } fn set_window_size(&mut self, new_width: u32, new_height: u32) { + // The requested size is the content size, as in Conf::window_width/ + // window_height and the other backends; the frame adds the title bar. + let content = NSRect { + origin: NSPoint { x: 0., y: 0. }, + size: NSSize { + width: new_width as f64, + height: new_height as f64, + }, + }; + let new_frame: NSRect = unsafe { msg_send![self.window, frameRectForContentRect: content] }; let mut frame: NSRect = unsafe { msg_send![self.window, frame] }; frame.origin.y += frame.size.height; - frame.origin.y -= new_height as f64; - frame.size = NSSize { - width: new_width as f64, - height: new_height as f64, - }; + frame.origin.y -= new_frame.size.height; + frame.size = new_frame.size; let () = unsafe { msg_send![self.window, setFrame:frame display:true animate:true] }; } fn set_fullscreen(&mut self, fullscreen: bool) {