diff options
author | tomaka <pierre.krieger1708@gmail.com> | 2015-12-30 15:28:39 +0100 |
---|---|---|
committer | tomaka <pierre.krieger1708@gmail.com> | 2015-12-30 15:28:39 +0100 |
commit | cab61a1367187199e14e8f3b24596c4a4ec7e22f (patch) | |
tree | dcfb1e3fd82e1a1df1e20969290e3073dd70505e /src/platform/linux/api_dispatch.rs | |
parent | 8236564a5224e38cd6e345df8ffaf343bfa24320 (diff) | |
parent | 82f5cd82729d12dbc8aec7e3bad3ed59dfd1f8e1 (diff) | |
download | glutin-cab61a1367187199e14e8f3b24596c4a4ec7e22f.tar.gz glutin-cab61a1367187199e14e8f3b24596c4a4ec7e22f.zip |
Merge pull request #679 from tomaka/x-error
Add better X error handling
Diffstat (limited to 'src/platform/linux/api_dispatch.rs')
-rw-r--r-- | src/platform/linux/api_dispatch.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/platform/linux/api_dispatch.rs b/src/platform/linux/api_dispatch.rs index a304f7a..8bf0ae5 100644 --- a/src/platform/linux/api_dispatch.rs +++ b/src/platform/linux/api_dispatch.rs @@ -19,6 +19,7 @@ use libc; use api::wayland; use api::x11; use api::x11::XConnection; +use api::x11::XError; use api::x11::XNotSupported; enum Backend { @@ -399,8 +400,16 @@ unsafe extern "C" fn x_error_callback(dpy: *mut x11::ffi::Display, event: *mut x 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); + let description = CStr::from_ptr(buff.as_mut_ptr() as *const i8).to_string_lossy(); + + let error = XError { + description: description.into_owned(), + error_code: (*event).error_code, + request_code: (*event).request_code, + minor_code: (*event).minor_code, + }; + + *x.latest_error.lock().unwrap() = Some(error); } 0 |