macos: report max_fps in ScreenInfo
Other platforms can be added later
This commit is contained in:
1 parent
8ca3faa6ee
commit
4fead3171e
8 files changed
+27
-4
No files matched your search
@@ -52,4 +52,4 @@ The screen information is a table with the following keys:
|
||||
|
||||
* `name` - the name of the screen.
|
||||
* `x`, `y`, `width`, `height` - the bounds of this screen
|
||||
|
||||
* `max_fps` - the maximum refresh rate supported by the screen, if known, or `nil` otherwise. (*Since: nightly builds only*)
|
||||
@@ -20,6 +20,7 @@ pub struct ScreenInfo {
|
||||
pub width: isize,
|
||||
pub height: isize,
|
||||
pub scale: f64,
|
||||
pub max_fps: Option<usize>,
|
||||
}
|
||||
impl_lua_conversion_dynamic!(ScreenInfo);
|
||||
|
||||
@@ -44,6 +45,7 @@ impl From<window::screen::ScreenInfo> for ScreenInfo {
|
||||
width: info.rect.width(),
|
||||
height: info.rect.height(),
|
||||
scale: info.scale,
|
||||
max_fps: info.max_fps,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ use crate::spawn::*;
|
||||
use crate::Appearance;
|
||||
use cocoa::appkit::{NSApp, NSApplication, NSApplicationActivationPolicyRegular, NSScreen};
|
||||
use cocoa::base::{id, nil};
|
||||
use cocoa::foundation::{NSArray, NSRect};
|
||||
use cocoa::foundation::{NSArray, NSInteger, NSRect};
|
||||
use objc::runtime::Object;
|
||||
use objc::*;
|
||||
use std::cell::RefCell;
|
||||
@@ -165,10 +165,12 @@ 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) };
|
||||
ScreenInfo {
|
||||
name,
|
||||
rect,
|
||||
scale: 1.0,
|
||||
max_fps: Some(max_fps as usize),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -480,7 +480,15 @@ impl ConnectionOps for WaylandConnection {
|
||||
let scale = info.scale_factor as f64;
|
||||
|
||||
virtual_rect = virtual_rect.union(&rect);
|
||||
by_name.insert(name.clone(), ScreenInfo { name, rect, scale });
|
||||
by_name.insert(
|
||||
name.clone(),
|
||||
ScreenInfo {
|
||||
name,
|
||||
rect,
|
||||
scale,
|
||||
max_fps: None,
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -229,7 +229,15 @@ impl OutputHandler {
|
||||
height as isize,
|
||||
);
|
||||
virtual_rect = virtual_rect.union(&rect);
|
||||
by_name.insert(name.clone(), ScreenInfo { name, rect, scale });
|
||||
by_name.insert(
|
||||
name.clone(),
|
||||
ScreenInfo {
|
||||
name,
|
||||
rect,
|
||||
scale,
|
||||
max_fps: None,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
if by_name.is_empty() {
|
||||
|
||||
@@ -154,6 +154,7 @@ impl ConnectionOps for Connection {
|
||||
mi.rcMonitor.bottom as isize - mi.rcMonitor.top as isize,
|
||||
),
|
||||
scale: 1.0,
|
||||
max_fps: None,
|
||||
};
|
||||
|
||||
info.virtual_rect = info.virtual_rect.union(&screen_info.rect);
|
||||
|
||||
@@ -187,6 +187,7 @@ impl ConnectionOps for XConnection {
|
||||
name: name.clone(),
|
||||
rect: bounds,
|
||||
scale: 1.0,
|
||||
max_fps: None,
|
||||
};
|
||||
by_name.insert(name, info);
|
||||
}
|
||||
|
||||
@@ -14,4 +14,5 @@ pub struct ScreenInfo {
|
||||
pub name: String,
|
||||
pub rect: ScreenRect,
|
||||
pub scale: f64,
|
||||
pub max_fps: Option<usize>,
|
||||
}
|
||||
Reference in new issue
Block a user