winit icon indicating copy to clipboard operation
winit copied to clipboard

Expose monitor physical size as `MonitorHandleProvider` method

Open remimimimimi opened this issue 10 months ago • 3 comments

Add support for querying the physical size of a monitor (in millimeters) via a new physical_size() method on the MonitorHandleProvider trait. Currently X11, Wayland, Windows, MacOS backends are updated. Other platforms are either don't support this functionality or it is hard to implement it. If no implementation possible, method will simply return None.

Resolves #3858 and partially resolves #4187.

  • [x] Tested on all platforms changed: I manually tested on Linux, MacOS, and Windows, other platforms return None.
  • [x] Added an entry to the changelog module if knowledge of this change could be valuable to users
  • [x] 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

remimimimimi avatar May 02 '25 17:05 remimimimimi

The CI failure is due to typos in files from previous commits.

remimimimimi avatar May 02 '25 20:05 remimimimimi

Thanks for the PR!

madsmtm avatar May 02 '25 21:05 madsmtm

CI fail seems unrelated to PR.

Couple of notes after testing different platforms:

  1. Wayland and MacOS swaps values when original orientation is changed by 90 or 270 degrees. Since we don't expose display orientation yet, I decided to adjust implementation for other systems to match this behavior.
  2. Wayland returns only centimeter precision. It seems that to change it, contribution to libdisplay-info is needed, as smithay uses this library.
  3. Previous implementation for windows returned incorrect values on resolution change. Thanks to @madsmtm comment this problem is now fixed.

Relevant comments were added to the documentation.

remimimimimi avatar May 06 '25 22:05 remimimimimi