macOS: Store UUID in MonitorHandle instead of CGDirectDisplayID (#4167)

The monitor UUID is what actually represents the monitor,
CGDirectDisplayID is closer in correspondence to a specific framebuffer.
This commit is contained in:
Mads Marquart 2025-04-29 12:26:03 +02:00 committed by GitHub
parent a5e6d0aaaf
commit 1800fa1670
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 106 additions and 54 deletions

View file

@ -1756,7 +1756,8 @@ impl WindowDelegate {
// Allow directly accessing the current monitor internally without unwrapping.
pub(crate) fn current_monitor_inner(&self) -> Option<MonitorHandle> {
let display_id = get_display_id(&*self.window().screen()?);
Some(MonitorHandle::new(display_id))
// Display ID just fetched from live NSScreen, should be fine to unwrap.
Some(MonitorHandle::new(display_id).expect("invalid display ID"))
}
#[inline]