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
This commit is contained in:
张小白 2024-04-13 03:19:49 +08:00 committed by GitHub
parent 4e6f24a841
commit 104558115f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -121,21 +121,18 @@ impl WindowsDisplay {
} }
pub(crate) fn frequency(&self) -> Option<u32> { pub(crate) fn frequency(&self) -> Option<u32> {
available_monitors() get_monitor_info(self.handle).ok().and_then(|info| {
.get(self.display_id.0 as usize) let mut devmode = DEVMODEW::default();
.and_then(|hmonitor| get_monitor_info(*hmonitor).ok()) unsafe {
.and_then(|info| { EnumDisplaySettingsW(
let mut devmode = DEVMODEW::default(); PCWSTR(info.szDevice.as_ptr()),
unsafe { ENUM_CURRENT_SETTINGS,
EnumDisplaySettingsW( &mut devmode,
PCWSTR(info.szDevice.as_ptr()), )
ENUM_CURRENT_SETTINGS, }
&mut devmode, .as_bool()
) .then(|| devmode.dmDisplayFrequency)
} })
.as_bool()
.then(|| devmode.dmDisplayFrequency)
})
} }
} }