diff --git a/src/changelog/unreleased.md b/src/changelog/unreleased.md index 341a6480..63d9856d 100644 --- a/src/changelog/unreleased.md +++ b/src/changelog/unreleased.md @@ -254,3 +254,4 @@ changelog entry. - On Wayland, fixed a crash when consequently calling `set_cursor_grab` without pointer focus. - On Wayland, ensure that external event loop is woken-up when using pump_events and integrating via `FD`. - On Wayland, apply fractional scaling to custom cursors. +- On macOS, fixed `VideoMode::refresh_rate_millihertz` for fractional refresh rates. diff --git a/src/platform_impl/apple/appkit/monitor.rs b/src/platform_impl/apple/appkit/monitor.rs index de33e62a..830771fe 100644 --- a/src/platform_impl/apple/appkit/monitor.rs +++ b/src/platform_impl/apple/appkit/monitor.rs @@ -126,13 +126,12 @@ impl MonitorHandle { let modes = unsafe { CFRetained::cast_unchecked::>(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 };