diff options
author | tomaka <pierre.krieger1708@gmail.com> | 2015-12-17 08:14:55 +0100 |
---|---|---|
committer | tomaka <pierre.krieger1708@gmail.com> | 2015-12-17 08:14:55 +0100 |
commit | 20a6e1ea6e6b08c2ed356eb21dd777016726a82b (patch) | |
tree | 074dc496142c4364522bdef09aea0f38eb00a4bf /src/platform | |
parent | 4f0aeafbed98e62515f5d10108f377a9b188cb4c (diff) | |
parent | a69ded9c8a77e8177e1bb972043cdd05371c564d (diff) | |
download | glutin-20a6e1ea6e6b08c2ed356eb21dd777016726a82b.tar.gz glutin-20a6e1ea6e6b08c2ed356eb21dd777016726a82b.zip |
Merge pull request #675 from ecoal95/x-error-reporting
x11: Improve xlib error reporting
Diffstat (limited to 'src/platform')
-rw-r--r-- | src/platform/linux/api_dispatch.rs | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/platform/linux/api_dispatch.rs b/src/platform/linux/api_dispatch.rs index a3c3bf9..f39ae43 100644 --- a/src/platform/linux/api_dispatch.rs +++ b/src/platform/linux/api_dispatch.rs @@ -33,7 +33,7 @@ lazy_static!( if false && wayland::is_available() { Backend::Wayland } else { - match XConnection::new() { + match XConnection::new(Some(x_error_callback)) { Ok(x) => Backend::X(Arc::new(x)), Err(e) => Backend::Error(e), } @@ -115,7 +115,7 @@ impl MonitorId { match self { &MonitorId::X(ref m) => m.get_native_identifier(), &MonitorId::Wayland(ref m) => m.get_native_identifier(), - &MonitorId::None => unimplemented!() // FIXME: + &MonitorId::None => unimplemented!() // FIXME: } } @@ -124,7 +124,7 @@ impl MonitorId { match self { &MonitorId::X(ref m) => m.get_dimensions(), &MonitorId::Wayland(ref m) => m.get_dimensions(), - &MonitorId::None => (800, 600), // FIXME: + &MonitorId::None => (800, 600), // FIXME: } } } @@ -390,3 +390,18 @@ impl GlContext for Window { } } } + +unsafe extern "C" fn x_error_callback(dpy: *mut x11::ffi::Display, event: *mut x11::ffi::XErrorEvent) + -> libc::c_int +{ + use std::ffi::CStr; + + if let Backend::X(ref x) = *BACKEND { + let mut buff: Vec<u8> = Vec::with_capacity(1024); + (x.xlib.XGetErrorText)(dpy, (*event).error_code as i32, buff.as_mut_ptr() as *mut i8, buff.capacity() as i32); + let error = CStr::from_ptr(buff.as_mut_ptr() as *const i8).to_string_lossy(); + println!("[glutin] x error code={} major={} minor={}: {}!", (*event).error_code, (*event).request_code, (*event).minor_code, error); + } + + 0 +} |