Skip to main content

Module monitor

Module monitor 

Source
Expand description

Monitor enumeration: geometry, work area, scale and refresh rate.

§Why monitor ids are a plain newtype and window ids are generational

WindowId is a Handle because a window is an object the engine creates, destroys and then keeps a stale reference to — the exact failure a generation counter catches. A monitor is not created by anyone; it is observed. The backend enumerates whatever the server advertises, and the only stale-id hazard is a monitor unplugged between Shell::monitors and the call that used its id.

That hazard is handled by an obligation instead of a generation: a MonitorId is never reused within a shell session. A backend that recycles ids (RandR output ids and Wayland registry names both can, after a hotplug cycle) must map them through its own table. The failure mode is then a clean ShellError::NoSuchMonitor rather than a borderless window appearing on the wrong display.

§Refresh rate is millihertz

Because 59.94 Hz exists, is extremely common, and is not 60. An integer millihertz value is exact for every mode any of these APIs report (wl_output.mode is already millihertz; RandR gives dot clock and totals; Win32 gives integer Hz, and macOS a Double), and it avoids putting a float in a PartialEq-compared struct that a settings screen will diff.

Structs§

MonitorId
Identifier of a connected monitor.
MonitorInfo
What the shell knows about one monitor.