fix refresh_rate_millihertz on macOS (#3254)
* fix refresh_rate_millihertz on macOS * round after conversion to mHz * add changelog entry
This commit is contained in:
parent
da947992ac
commit
f735f028a1
2 changed files with 10 additions and 1 deletions
|
|
@ -16,6 +16,7 @@ Unreleased` header.
|
||||||
- On X11, fix an issue where floating point data from the server is
|
- On X11, fix an issue where floating point data from the server is
|
||||||
misinterpreted during a drag and drop operation.
|
misinterpreted during a drag and drop operation.
|
||||||
- On X11, fix a bug where focusing the window would panic.
|
- On X11, fix a bug where focusing the window would panic.
|
||||||
|
- On macOS, fix `refresh_rate_millihertz`.
|
||||||
|
|
||||||
# 0.29.4
|
# 0.29.4
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,9 @@ use core_foundation::{
|
||||||
base::{CFRelease, TCFType},
|
base::{CFRelease, TCFType},
|
||||||
string::CFString,
|
string::CFString,
|
||||||
};
|
};
|
||||||
use core_graphics::display::{CGDirectDisplayID, CGDisplay, CGDisplayBounds};
|
use core_graphics::display::{
|
||||||
|
CGDirectDisplayID, CGDisplay, CGDisplayBounds, CGDisplayCopyDisplayMode,
|
||||||
|
};
|
||||||
use objc2::rc::Id;
|
use objc2::rc::Id;
|
||||||
|
|
||||||
use super::appkit::NSScreen;
|
use super::appkit::NSScreen;
|
||||||
|
|
@ -216,6 +218,12 @@ impl MonitorHandle {
|
||||||
|
|
||||||
pub fn refresh_rate_millihertz(&self) -> Option<u32> {
|
pub fn refresh_rate_millihertz(&self) -> Option<u32> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
let current_display_mode = NativeDisplayMode(CGDisplayCopyDisplayMode(self.0) as _);
|
||||||
|
let refresh_rate = ffi::CGDisplayModeGetRefreshRate(current_display_mode.0);
|
||||||
|
if refresh_rate > 0.0 {
|
||||||
|
return Some((refresh_rate * 1000.0).round() as u32);
|
||||||
|
}
|
||||||
|
|
||||||
let mut display_link = std::ptr::null_mut();
|
let mut display_link = std::ptr::null_mut();
|
||||||
if ffi::CVDisplayLinkCreateWithCGDisplay(self.0, &mut display_link)
|
if ffi::CVDisplayLinkCreateWithCGDisplay(self.0, &mut display_link)
|
||||||
!= ffi::kCVReturnSuccess
|
!= ffi::kCVReturnSuccess
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue