From 104558115ff0e218ce6f6e8bb6a48e114a580565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=B0=8F=E7=99=BD?= <364772080@qq.com> Date: Sat, 13 Apr 2024 03:19:49 +0800 Subject: [PATCH] windows: Update `WindowsDisplay::frequency()` (#10476) A subsequent update introduced the `HMONITOR` value to the `WindowsDisplay` struct, eliminating the need for polling to retrieve this value. Release Notes: - N/A --- crates/gpui/src/platform/windows/display.rs | 27 +++++++++------------ 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/crates/gpui/src/platform/windows/display.rs b/crates/gpui/src/platform/windows/display.rs index 64a641aebb..151d0b7151 100644 --- a/crates/gpui/src/platform/windows/display.rs +++ b/crates/gpui/src/platform/windows/display.rs @@ -121,21 +121,18 @@ impl WindowsDisplay { } pub(crate) fn frequency(&self) -> Option { - available_monitors() - .get(self.display_id.0 as usize) - .and_then(|hmonitor| get_monitor_info(*hmonitor).ok()) - .and_then(|info| { - let mut devmode = DEVMODEW::default(); - unsafe { - EnumDisplaySettingsW( - PCWSTR(info.szDevice.as_ptr()), - ENUM_CURRENT_SETTINGS, - &mut devmode, - ) - } - .as_bool() - .then(|| devmode.dmDisplayFrequency) - }) + get_monitor_info(self.handle).ok().and_then(|info| { + let mut devmode = DEVMODEW::default(); + unsafe { + EnumDisplaySettingsW( + PCWSTR(info.szDevice.as_ptr()), + ENUM_CURRENT_SETTINGS, + &mut devmode, + ) + } + .as_bool() + .then(|| devmode.dmDisplayFrequency) + }) } }