diff --git a/src/x11/window.rs b/src/x11/window.rs index 244824f..9128f65 100644 --- a/src/x11/window.rs +++ b/src/x11/window.rs @@ -283,6 +283,10 @@ impl Window { let mut fds = [PollFd::new(xcb_fd, PollFlags::POLLIN)]; + // Check for any events in the internal buffers + // before going to sleep: + self.drain_xcb_events(handler); + // FIXME: handle errors poll(&mut fds, until_next_frame.subsec_millis() as i32).unwrap(); diff --git a/src/x11/xcb_connection.rs b/src/x11/xcb_connection.rs index 0be7aa1..66e6f8d 100644 --- a/src/x11/xcb_connection.rs +++ b/src/x11/xcb_connection.rs @@ -46,6 +46,8 @@ impl XcbConnection { pub fn new() -> Result { let (conn, xlib_display) = xcb::Connection::connect_with_xlib_display()?; + conn.set_event_queue_owner(xcb::base::EventQueueOwner::Xcb); + let (wm_protocols, wm_delete_window, wm_normal_hints) = intern_atoms!(&conn, WM_PROTOCOLS, WM_DELETE_WINDOW, WM_NORMAL_HINTS); Ok(Self {