Fix #9263

Release Notes:

- N/A
This commit is contained in:
Mikayla Maki 2024-06-25 11:35:50 -07:00 committed by GitHub
parent 41d2c52638
commit e5d1cf84cf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1167,6 +1167,10 @@ impl LinuxClient for X11Client {
// Adatpted from:
// https://docs.rs/winit/0.29.11/src/winit/platform_impl/linux/x11/monitor.rs.html#103-111
pub fn mode_refresh_rate(mode: &randr::ModeInfo) -> Duration {
if mode.dot_clock == 0 || mode.htotal == 0 || mode.vtotal == 0 {
return Duration::from_millis(16);
}
let millihertz = mode.dot_clock as u64 * 1_000 / (mode.htotal as u64 * mode.vtotal as u64);
let micros = 1_000_000_000 / millihertz;
log::info!("Refreshing at {} micros", micros);