expose platform-native monitor identifier
This commit is contained in:
parent
0fa5e541e8
commit
9914d826b8
6 changed files with 43 additions and 1 deletions
|
|
@ -500,6 +500,19 @@ pub fn get_primary_monitor() -> MonitorID {
|
|||
MonitorID(winimpl::get_primary_monitor())
|
||||
}
|
||||
|
||||
/// Native platform identifier for a monitor. Different platforms use fundamentally different types
|
||||
/// to represent a monitor ID.
|
||||
pub enum NativeMonitorID {
|
||||
/// Cocoa and X11 use a numeric identifier to represent a monitor.
|
||||
Numeric(u32),
|
||||
|
||||
/// Win32 uses a Unicode string to represent a monitor.
|
||||
Name(String),
|
||||
|
||||
/// Other platforms (Android) don't support monitor identification.
|
||||
Unavailable
|
||||
}
|
||||
|
||||
/// Identifier for a monitor.
|
||||
pub struct MonitorID(winimpl::MonitorID);
|
||||
|
||||
|
|
@ -510,6 +523,12 @@ impl MonitorID {
|
|||
id.get_name()
|
||||
}
|
||||
|
||||
/// Returns the native platform identifier for this monitor.
|
||||
pub fn get_native_identifier(&self) -> NativeMonitorID {
|
||||
let &MonitorID(ref id) = self;
|
||||
id.get_native_identifier()
|
||||
}
|
||||
|
||||
/// Returns the number of pixels currently displayed on the monitor.
|
||||
pub fn get_dimensions(&self) -> (u32, u32) {
|
||||
let &MonitorID(ref id) = self;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue