Skip to content

native/macos: set_window_size sets the content size - #706

Open
nivaldomcj wants to merge 1 commit into
not-fl3:masterfrom
nivaldomcj:macos-window-size-content
Open

nivaldomcj wants to merge 1 commit into
not-fl3:masterfrom
nivaldomcj:macos-window-size-content

Conversation

@nivaldomcj

@nivaldomcj nivaldomcj commented Nov 23, 2026 •

Copy link
Copy Markdown

On macOS, window::set_window_size(w, h) passes w×h to setFrame:, and the window frame includes the title bar, so the drawable area ends up a title bar short. Starting from a 400×300 window, set_window_size(500, 400) gives a screen_size() of 500×368.

Conf::window_width/window_height are content sizes on macOS, and set_window_size sets the content size on Windows (it grows the client rect to the frame) and on X11 (XResizeWindow). This PR converts the requested size with frameRectForContentRect: before calling setFrame:. The top edge stays where it was and the resize still animates.

I tested it on an Apple Silicon Mac with a small program that calls set_window_size(500, 400) and prints screen_size():

Display high_dpi Before After
1x (2560×1080) false 500×368 500×400
1x true 500×368 500×400
Retina false 500×368 500×400
Retina true 1000×736 1000×800

Tested on macOS 27.2.1 (26B131), Apple M3 Max (arm64), Rust 1.100.0.

cargo build --all-targets passes for aarch64-apple-darwin and x86_64-apple-darwin, and cargo check --all-targets for aarch64-apple-ios and x86_64-apple-ios.

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 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant