macOS: Store UUID in MonitorHandle instead of CGDirectDisplayID

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-03-17 09:18:14 +01:00
committed by Kirill Chibisov
parent 57baf72741
commit 5f1e9f6cc1
4 changed files with 54 additions and 25 deletions

View File

@@ -1592,7 +1592,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]