Fix Window::set_inner_size()#2858
Merged
Merged
Conversation
Contributor
|
I'm against this change - I think the old behaviour was correct. A CSS "pixel" is not a physical pixel, it's a logical pixel. On a screen with a scale factor of 2, one CSS pixel represents a 2x2 grid of physical pixels. So, setting the CSS size of the canvas to the logical size of the window was correct. |
This was referenced Jun 9, 2023
Member
Author
|
Reverted in #2861. |
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.
So since #2778 properly decoupling internal and visual canvas size, we should make things consistent.
Before (#2778)
Using
Window::set_inner_size()would apply physical pixels to the internal canvas size and logical pixel to the visual canvas size. The logical pixel would be applied to the canvas size as physical pixels by setting CSS width and height aspxvalues.E.g.:
Window::set_inner_size(PhysicalSize::new(500, 500))with a scale factor of 2. Would apply 500x500px to the the internal canvas size and 250x250px to the visual size.Window::inner_size()would report a size of 500x500px.In the meanwhile the reported size by
Window::inner_size()would be theCurrently (after #2778)
Same as before, but it would only apply the visual size, internal size wouldn't be touched at all.
After (this PR)
Window::set_inner_size()will apply the correct size to the canvas. E.g.Window::set_inner_size(PhysicalSize::new(500, 500))will apply 500x500px to the visual size of the canvas, no matter the current scale factor.