diff options
author | tomaka <pierre.krieger1708@gmail.com> | 2015-04-24 19:27:41 +0200 |
---|---|---|
committer | tomaka <pierre.krieger1708@gmail.com> | 2015-04-24 19:27:41 +0200 |
commit | d6c50df294a7832b1d9233aaa0c5e0bee8929c8f (patch) | |
tree | 3577f29635ebd3c1340740eee19250b716400578 /src/api/x11/window/monitor.rs | |
parent | 4dee36631c520726179139bd543453ff0f3b78d6 (diff) | |
parent | a72e06cf1b8f0e037be8a0e3152b9b0ab9ef2c95 (diff) | |
download | glutin-d6c50df294a7832b1d9233aaa0c5e0bee8929c8f.tar.gz glutin-d6c50df294a7832b1d9233aaa0c5e0bee8929c8f.zip |
Merge pull request #395 from tomaka/x-reorg
Reorganize the Linux implementation and split OSMesa and X11
Diffstat (limited to 'src/api/x11/window/monitor.rs')
-rw-r--r-- | src/api/x11/window/monitor.rs | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/src/api/x11/window/monitor.rs b/src/api/x11/window/monitor.rs deleted file mode 100644 index 46f2062..0000000 --- a/src/api/x11/window/monitor.rs +++ /dev/null @@ -1,66 +0,0 @@ -use std::ptr; -use std::collections::VecDeque; -use super::super::ffi; -use super::ensure_thread_init; -use native_monitor::NativeMonitorId; - -pub struct MonitorID(pub u32); - -pub fn get_available_monitors() -> VecDeque<MonitorID> { - ensure_thread_init(); - let nb_monitors = unsafe { - let display = ffi::XOpenDisplay(ptr::null()); - if display.is_null() { - panic!("get_available_monitors failed"); - } - let nb_monitors = ffi::XScreenCount(display); - ffi::XCloseDisplay(display); - nb_monitors - }; - - let mut monitors = VecDeque::new(); - monitors.extend((0..nb_monitors).map(|i| MonitorID(i as u32))); - monitors -} - -pub fn get_primary_monitor() -> MonitorID { - ensure_thread_init(); - let primary_monitor = unsafe { - let display = ffi::XOpenDisplay(ptr::null()); - if display.is_null() { - panic!("get_available_monitors failed"); - } - let primary_monitor = ffi::XDefaultScreen(display); - ffi::XCloseDisplay(display); - primary_monitor - }; - - MonitorID(primary_monitor as u32) -} - -impl MonitorID { - pub fn get_name(&self) -> Option<String> { - let MonitorID(screen_num) = *self; - 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()); - let MonitorID(screen_num) = *self; - let screen = ffi::XScreenOfDisplay(display, screen_num as i32); - let width = ffi::XWidthOfScreen(screen); - let height = ffi::XHeightOfScreen(screen); - ffi::XCloseDisplay(display); - (width as u32, height as u32) - }; - - dimensions - } -} - |