mirror of
https://github.com/rust-windowing/winit.git
synced 2026-08-29 04:40:04 -04:00
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:
@@ -254,3 +254,4 @@ changelog entry.
|
|||||||
- On Wayland, fixed a crash when consequently calling `set_cursor_grab` without pointer focus.
|
- 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, 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 Wayland, apply fractional scaling to custom cursors.
|
||||||
|
- On macOS, fixed `VideoMode::refresh_rate_millihertz` for fractional refresh rates.
|
||||||
|
|||||||
@@ -126,13 +126,12 @@ impl MonitorHandle {
|
|||||||
let modes = unsafe { CFRetained::cast_unchecked::<CFArray<CGDisplayMode>>(array) };
|
let modes = unsafe { CFRetained::cast_unchecked::<CFArray<CGDisplayMode>>(array) };
|
||||||
|
|
||||||
modes.into_iter().map(move |mode| {
|
modes.into_iter().map(move |mode| {
|
||||||
let cg_refresh_rate_hertz =
|
let cg_refresh_rate_hertz = unsafe { CGDisplayMode::refresh_rate(Some(&mode)) };
|
||||||
unsafe { CGDisplayMode::refresh_rate(Some(&mode)) }.round() as i64;
|
|
||||||
|
|
||||||
// CGDisplayModeGetRefreshRate returns 0.0 for any display that
|
// CGDisplayModeGetRefreshRate returns 0.0 for any display that
|
||||||
// isn't a CRT
|
// isn't a CRT
|
||||||
let refresh_rate_millihertz = if cg_refresh_rate_hertz > 0 {
|
let refresh_rate_millihertz = if cg_refresh_rate_hertz > 0.0 {
|
||||||
NonZeroU32::new((cg_refresh_rate_hertz * 1000) as u32)
|
NonZeroU32::new((cg_refresh_rate_hertz * 1000.0).round() as u32)
|
||||||
} else {
|
} else {
|
||||||
refresh_rate_millihertz
|
refresh_rate_millihertz
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user