macos, periodically check if current display is changed

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2023-02-25 22:39:12 +08:00
parent f71d4e9e81
commit b8b3e99602
4 changed files with 14 additions and 7 deletions

View File

@@ -612,18 +612,18 @@ pub fn resolutions(name: &str) -> Vec<Resolution> {
unsafe {
if YES == MacGetModeNum(display, &mut num) {
let (mut widths, mut heights) = (vec![0; num as _], vec![0; num as _]);
let mut realNum = 0;
let mut real_num = 0;
if YES
== MacGetModes(
display,
widths.as_mut_ptr(),
heights.as_mut_ptr(),
num,
&mut realNum,
&mut real_num,
)
{
if realNum <= num {
for i in 0..realNum {
if real_num <= num {
for i in 0..real_num {
let resolution = Resolution {
width: widths[i as usize] as _,
height: heights[i as usize] as _,