Skip to content

Commit 50c4175

Browse files
Fix: Check for remaining events in the internal X11/xcb buffers (#86)
* Fix: Check for remaining events in the internal X11/xcb buffers before going to sleep. * Also need to set the queue owner to xcb as wrl suggested.
1 parent 68a5c4a commit 50c4175

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

src/x11/window.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,10 @@ impl Window {
283283

284284
let mut fds = [PollFd::new(xcb_fd, PollFlags::POLLIN)];
285285

286+
// Check for any events in the internal buffers
287+
// before going to sleep:
288+
self.drain_xcb_events(handler);
289+
286290
// FIXME: handle errors
287291
poll(&mut fds, until_next_frame.subsec_millis() as i32).unwrap();
288292

src/x11/xcb_connection.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ impl XcbConnection {
4646
pub fn new() -> Result<Self, xcb::base::ConnError> {
4747
let (conn, xlib_display) = xcb::Connection::connect_with_xlib_display()?;
4848

49+
conn.set_event_queue_owner(xcb::base::EventQueueOwner::Xcb);
50+
4951
let (wm_protocols, wm_delete_window, wm_normal_hints) = intern_atoms!(&conn, WM_PROTOCOLS, WM_DELETE_WINDOW, WM_NORMAL_HINTS);
5052

5153
Ok(Self {

0 commit comments

Comments
 (0)