Repository navigation
native/macos: set_window_size sets the content size - #706
Open
nivaldomcj wants to merge 1 commit into
Open
nivaldomcj wants to merge 1 commit into
nivaldomcj wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On macOS,
window::set_window_size(w, h)passesw×htosetFrame:, 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 ascreen_size()of 500×368.Conf::window_width/window_heightare content sizes on macOS, andset_window_sizesets the content size on Windows (it grows the client rect to the frame) and on X11 (XResizeWindow). This PR converts the requested size withframeRectForContentRect:before callingsetFrame:. 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 printsscreen_size():high_dpiTested on macOS 27.2.1 (26B131), Apple M3 Max (arm64), Rust 1.100.0.
cargo build --all-targetspasses for aarch64-apple-darwin and x86_64-apple-darwin, andcargo check --all-targetsfor aarch64-apple-ios and x86_64-apple-ios.