Skip to content

Make MonitorHandleProvider::scale_factor return an Option - #4699

Open
dhardy wants to merge 1 commit into
rust-windowing:masterfrom
dhardy:push-snuttzpkotym
Open

dhardy wants to merge 1 commit into
rust-windowing:masterfrom
dhardy:push-snuttzpkotym

Conversation

@dhardy

@dhardy dhardy commented Sep 18, 2026

Copy link
Copy Markdown
Contributor
  • Tested on all platforms changed
  • Added an entry to the changelog module if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • Created or updated an example program if it would help users understand this functionality

Previously this method forced return of a result, leading to:

  • Defaulting to 1.0 if unavailable on Android and appkit
  • Defaulting to 0.0 if unavailable on Web
  • Defaulting to 96 DPI if unavailable on win32
  • Reporting of the integer scale value on Wayland

My primary motivation is actually the last case: I would prefer to receive None (so that I can use a workaround) than an incorrect value (on my current screen, the existing code reports 2.0 while the actual factor is 1.45).

@dhardy
dhardy force-pushed the push-snuttzpkotym branch 2 times, most recently from 25dc3ab to 8bd1bd2 Compare September 23, 2026 09:24
@dhardy

dhardy commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

Rebased; CI errors fixed.

@ogoffart

Copy link
Copy Markdown
Contributor

Reporting of the integer scale value on Wayland

Is it not better to report the integer scale rather than no scale at all?
Is it not possible to get the fractional scale from that function?

@dhardy

dhardy commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor Author

I'm not a Wayland expert, but if I understand correctly the fractional scale protocol can only be used with surfaces (i.e. windows), not displays. The base Wayland protocol only supports integer scaling.

Personally I have no use for an incorrect scale factor. Does anyone else? It seems a little unlikely. The only reason I care about this API at all is because I want to be able to perform my own not-quite-linear fractional scaling before sizing the window. (Edit: I simplified my code recently to stop using this API at all by just delaying sizing of the window until after creation. It seems to work well so far but there could be issues on other platforms and/or with multiple monitors.)

I can restore that if you like (with a clearer warning about fractional scaling) but I suspect it would be more likely to cause bugs than actually help.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants