1
0
Fork 0

Call XCloseDisplay instead of xcb_disconnect (#184)

This commit is contained in:
Micah Johnston 2024-03-28 22:09:23 -05:00 committed by GitHub
parent 70e7af6c61
commit f5b0c6d460
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -40,7 +40,7 @@ impl XcbConnection {
let xcb_connection = unsafe { xlib_xcb::XGetXCBConnection(dpy) }; let xcb_connection = unsafe { xlib_xcb::XGetXCBConnection(dpy) };
assert!(!xcb_connection.is_null()); assert!(!xcb_connection.is_null());
let screen = unsafe { xlib::XDefaultScreen(dpy) } as usize; let screen = unsafe { xlib::XDefaultScreen(dpy) } as usize;
let conn = unsafe { XCBConnection::from_raw_xcb_connection(xcb_connection, true)? }; let conn = unsafe { XCBConnection::from_raw_xcb_connection(xcb_connection, false)? };
unsafe { unsafe {
xlib_xcb::XSetEventQueueOwner(dpy, xlib_xcb::XEventQueueOwner::XCBOwnsEventQueue) xlib_xcb::XSetEventQueueOwner(dpy, xlib_xcb::XEventQueueOwner::XCBOwnsEventQueue)
}; };
@ -119,3 +119,11 @@ impl XcbConnection {
&self.conn.setup().roots[self.screen] &self.conn.setup().roots[self.screen]
} }
} }
impl Drop for XcbConnection {
fn drop(&mut self) {
unsafe {
xlib::XCloseDisplay(self.dpy);
}
}
}