aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/android/mod.rs5
-rw-r--r--src/cocoa/monitor.rs6
-rw-r--r--src/lib.rs2
-rw-r--r--src/win32/monitor.rs7
-rw-r--r--src/window.rs19
-rw-r--r--src/x11/window/monitor.rs5
6 files changed, 43 insertions, 1 deletions
diff --git a/src/android/mod.rs b/src/android/mod.rs
index 7979f09..c75878b 100644
--- a/src/android/mod.rs
+++ b/src/android/mod.rs
@@ -14,6 +14,7 @@ use std::collections::VecDeque;
use Api;
use BuilderAttribs;
use GlRequest;
+use NativeMonitorID;
pub struct Window {
display: ffi::egl::types::EGLDisplay,
@@ -41,6 +42,10 @@ impl MonitorID {
Some("Primary".to_string())
}
+ pub fn get_native_identifier(&self) -> NativeMonitorID {
+ NativeMonitorID::Unavailable
+ }
+
pub fn get_dimensions(&self) -> (u32, u32) {
unimplemented!()
}
diff --git a/src/cocoa/monitor.rs b/src/cocoa/monitor.rs
index 47adc03..1902f6a 100644
--- a/src/cocoa/monitor.rs
+++ b/src/cocoa/monitor.rs
@@ -1,5 +1,6 @@
use core_graphics::display;
use std::collections::VecDeque;
+use window::NativeMonitorID;
pub struct MonitorID(u32);
@@ -35,6 +36,11 @@ impl MonitorID {
Some(format!("Monitor #{}", screen_num))
}
+ pub fn get_native_identifier(&self) -> NativeMonitorID {
+ let MonitorID(display_id) = *self;
+ NativeMonitorID::Numeric(display_id)
+ }
+
pub fn get_dimensions(&self) -> (u32, u32) {
let MonitorID(display_id) = *self;
let dimension = unsafe {
diff --git a/src/lib.rs b/src/lib.rs
index 916b699..20bd723 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -50,7 +50,7 @@ pub use headless::{HeadlessRendererBuilder, HeadlessContext};
#[cfg(feature = "window")]
pub use window::{WindowBuilder, Window, WindowProxy, PollEventsIterator, WaitEventsIterator};
#[cfg(feature = "window")]
-pub use window::{AvailableMonitorsIter, MonitorID, get_available_monitors, get_primary_monitor};
+pub use window::{AvailableMonitorsIter, NativeMonitorID, MonitorID, get_available_monitors, get_primary_monitor};
#[cfg(all(not(target_os = "windows"), not(target_os = "linux"), not(target_os = "macos"), not(target_os = "android")))]
use this_platform_is_not_supported;
diff --git a/src/win32/monitor.rs b/src/win32/monitor.rs
index fc9f20d..5fbd5dd 100644
--- a/src/win32/monitor.rs
+++ b/src/win32/monitor.rs
@@ -3,6 +3,8 @@ use user32;
use std::collections::VecDeque;
+use NativeMonitorID;
+
/// Win32 implementation of the main `MonitorID` object.
pub struct MonitorID {
/// The system name of the monitor.
@@ -113,6 +115,11 @@ impl MonitorID {
Some(self.readable_name.clone())
}
+ /// See the docs of the crate root file.
+ pub fn get_native_identifier(&self) -> NativeMonitorID {
+ NativeMonitorID::Name(self.readable_name.clone())
+ }
+
/// See the docs if the crate root file.
pub fn get_dimensions(&self) -> (u32, u32) {
// TODO: retreive the dimensions every time this is called
diff --git a/src/window.rs b/src/window.rs
index 56af494..4b02874 100644
--- a/src/window.rs
+++ b/src/window.rs
@@ -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;
diff --git a/src/x11/window/monitor.rs b/src/x11/window/monitor.rs
index 77ac4ec..a99f2f2 100644
--- a/src/x11/window/monitor.rs
+++ b/src/x11/window/monitor.rs
@@ -43,6 +43,11 @@ impl MonitorID {
Some(format!("Monitor #{}", screen_num))
}
+ pub fn get_native_identifier(&self) -> NativeMonitorID {
+ let MonitorID(screen_num) = *self;
+ NativeMonitorID::Numeric(screen_num)
+ }
+
pub fn get_dimensions(&self) -> (u32, u32) {
let dimensions = unsafe {
let display = ffi::XOpenDisplay(ptr::null());