aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/x11/xdisplay.rs
diff options
context:
space:
mode:
authortomaka <pierre.krieger1708@gmail.com>2015-12-17 08:14:55 +0100
committertomaka <pierre.krieger1708@gmail.com>2015-12-17 08:14:55 +0100
commit20a6e1ea6e6b08c2ed356eb21dd777016726a82b (patch)
tree074dc496142c4364522bdef09aea0f38eb00a4bf /src/api/x11/xdisplay.rs
parent4f0aeafbed98e62515f5d10108f377a9b188cb4c (diff)
parenta69ded9c8a77e8177e1bb972043cdd05371c564d (diff)
downloadglutin-20a6e1ea6e6b08c2ed356eb21dd777016726a82b.tar.gz
glutin-20a6e1ea6e6b08c2ed356eb21dd777016726a82b.zip
Merge pull request #675 from ecoal95/x-error-reporting
x11: Improve xlib error reporting
Diffstat (limited to 'src/api/x11/xdisplay.rs')
-rw-r--r--src/api/x11/xdisplay.rs14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/api/x11/xdisplay.rs b/src/api/x11/xdisplay.rs
index 2b77d9c..8205c66 100644
--- a/src/api/x11/xdisplay.rs
+++ b/src/api/x11/xdisplay.rs
@@ -23,24 +23,18 @@ pub struct XConnection {
unsafe impl Send for XConnection {}
unsafe impl Sync for XConnection {}
+pub type XErrorHandler = Option<unsafe extern fn(*mut ffi::Display, *mut ffi::XErrorEvent) -> libc::c_int>;
+
impl XConnection {
- pub fn new() -> Result<XConnection, XNotSupported> {
+ pub fn new(error_handler: XErrorHandler) -> Result<XConnection, XNotSupported> {
// opening the libraries
let xlib = try!(ffi::Xlib::open());
let xcursor = try!(ffi::Xcursor::open());
let xf86vmode = try!(ffi::Xf86vmode::open());
let xinput2 = try!(ffi::XInput2::open());
- unsafe extern "C" fn x_error_callback(_: *mut ffi::Display, event: *mut ffi::XErrorEvent)
- -> libc::c_int
- {
- println!("[glutin] x error code={} major={} minor={}!", (*event).error_code,
- (*event).request_code, (*event).minor_code);
- 0
- }
-
unsafe { (xlib.XInitThreads)() };
- unsafe { (xlib.XSetErrorHandler)(Some(x_error_callback)) };
+ unsafe { (xlib.XSetErrorHandler)(error_handler) };
// TODO: use something safer than raw "dlopen"
let glx = {