aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/x11/monitor.rs
diff options
context:
space:
mode:
authortomaka <pierre.krieger1708@gmail.com>2015-12-30 15:28:39 +0100
committertomaka <pierre.krieger1708@gmail.com>2015-12-30 15:28:39 +0100
commitcab61a1367187199e14e8f3b24596c4a4ec7e22f (patch)
treedcfb1e3fd82e1a1df1e20969290e3073dd70505e /src/api/x11/monitor.rs
parent8236564a5224e38cd6e345df8ffaf343bfa24320 (diff)
parent82f5cd82729d12dbc8aec7e3bad3ed59dfd1f8e1 (diff)
downloadglutin-cab61a1367187199e14e8f3b24596c4a4ec7e22f.tar.gz
glutin-cab61a1367187199e14e8f3b24596c4a4ec7e22f.zip
Merge pull request #679 from tomaka/x-error
Add better X error handling
Diffstat (limited to 'src/api/x11/monitor.rs')
-rw-r--r--src/api/x11/monitor.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/api/x11/monitor.rs b/src/api/x11/monitor.rs
index 30bd522..d6479c9 100644
--- a/src/api/x11/monitor.rs
+++ b/src/api/x11/monitor.rs
@@ -9,6 +9,7 @@ pub struct MonitorId(pub Arc<XConnection>, pub u32);
pub fn get_available_monitors(x: &Arc<XConnection>) -> VecDeque<MonitorId> {
let nb_monitors = unsafe { (x.xlib.XScreenCount)(x.display) };
+ x.check_errors().expect("Failed to call XScreenCount");
let mut monitors = VecDeque::new();
monitors.extend((0 .. nb_monitors).map(|i| MonitorId(x.clone(), i as u32)));
@@ -18,6 +19,7 @@ pub fn get_available_monitors(x: &Arc<XConnection>) -> VecDeque<MonitorId> {
#[inline]
pub fn get_primary_monitor(x: &Arc<XConnection>) -> MonitorId {
let primary_monitor = unsafe { (x.xlib.XDefaultScreen)(x.display) };
+ x.check_errors().expect("Failed to call XDefaultScreen");
MonitorId(x.clone(), primary_monitor as u32)
}
@@ -36,6 +38,7 @@ impl MonitorId {
let screen = unsafe { (self.0.xlib.XScreenOfDisplay)(self.0.display, self.1 as i32) };
let width = unsafe { (self.0.xlib.XWidthOfScreen)(screen) };
let height = unsafe { (self.0.xlib.XHeightOfScreen)(screen) };
+ self.0.check_errors().expect("Failed to get monitor dimensions");
(width as u32, height as u32)
}
}