1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-22 22:42:48 +03:00

macos: NSScreen::maximumFramesPerSecond is newish

Gate calling it to avoid a runtime failure on eg: Big Sur.

refs: https://github.com/wez/wezterm/issues/2440
This commit is contained in:
Wez Furlong 2022-08-21 07:21:12 -07:00
parent 58eecab4f8
commit 99391e39d2

View File

@ -165,12 +165,19 @@ fn nsscreen_to_screen_info(screen: *mut Object) -> ScreenInfo {
frame.size.width as isize,
frame.size.height as isize,
);
let max_fps: NSInteger = unsafe { msg_send!(screen, maximumFramesPerSecond) };
let has_max_fps: objc::runtime::BOOL =
unsafe { msg_send!(screen, respondsToSelector: sel!(maximumFramesPerSecond)) };
let max_fps = if has_max_fps {
let max_fps: NSInteger = unsafe { msg_send!(screen, maximumFramesPerSecond) };
Some(max_fps as usize)
} else {
None
};
ScreenInfo {
name,
rect,
scale: 1.0,
max_fps: Some(max_fps as usize),
max_fps,
}
}