Retrieve DPI scale from window instead of screen #439
Merged
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.
Previously, DPI scale was retrieved based on the property from the screen. This PR changes this behaviour to instead retrieve it from the window. Previous behaviour on a macbook could result in a 3:2 ratio between the reported DPI scale and the window size:
WIth
high_dpi: false
:screen_size()
returns(1440.0, 900.0)
dpi_scale()
returns1.0
With
high_dpi: true
:screen_size()
returns(2880.0, 1800.0)
dpi_scale()
returns3.0
sometimes and2.0
somtimes.The apple docs provide virtually no guarantees for the
backingScaleFactor
property forNSScreen
, while the same documentation forNSWindow
explicitly states the returned value is either2.0
or1.0
. This seems to always line up with the value returned byscreen_size
, and intuitively I would also expect the value for the window to be of more interest tominiquad
than that of the display.