fix: Support fractional refresh rates in video modes on macOS (#4191)
We were rounding the refresh rate before converting it to millihertz.
This commit is contained in:
parent
4fe4ce3d77
commit
a5e6d0aaaf
2 changed files with 4 additions and 4 deletions
|
|
@ -126,13 +126,12 @@ impl MonitorHandle {
|
|||
let modes = unsafe { CFRetained::cast_unchecked::<CFArray<CGDisplayMode>>(array) };
|
||||
|
||||
modes.into_iter().map(move |mode| {
|
||||
let cg_refresh_rate_hertz =
|
||||
unsafe { CGDisplayMode::refresh_rate(Some(&mode)) }.round() as i64;
|
||||
let cg_refresh_rate_hertz = unsafe { CGDisplayMode::refresh_rate(Some(&mode)) };
|
||||
|
||||
// CGDisplayModeGetRefreshRate returns 0.0 for any display that
|
||||
// isn't a CRT
|
||||
let refresh_rate_millihertz = if cg_refresh_rate_hertz > 0 {
|
||||
NonZeroU32::new((cg_refresh_rate_hertz * 1000) as u32)
|
||||
let refresh_rate_millihertz = if cg_refresh_rate_hertz > 0.0 {
|
||||
NonZeroU32::new((cg_refresh_rate_hertz * 1000.0).round() as u32)
|
||||
} else {
|
||||
refresh_rate_millihertz
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue