mirror of
https://github.com/rust-windowing/winit.git
synced 2026-09-01 14:20:05 -04:00
Fix x11 poll_events to drain queue
It was only processing a single event per call. The docs say > Fetches all the events that are pending, calls the callback function > for each of them, and returns. which suggests that was incorrect.
This commit is contained in:
@@ -111,16 +111,22 @@ impl EventsLoop {
|
|||||||
let xlib = &self.display.xlib;
|
let xlib = &self.display.xlib;
|
||||||
|
|
||||||
let mut xev = unsafe { mem::uninitialized() };
|
let mut xev = unsafe { mem::uninitialized() };
|
||||||
unsafe {
|
loop {
|
||||||
// Ensure XNextEvent won't block
|
// Get next event
|
||||||
let count = (xlib.XPending)(self.display.display);
|
unsafe {
|
||||||
if count == 0 {
|
// Ensure XNextEvent won't block
|
||||||
return;
|
let count = (xlib.XPending)(self.display.display);
|
||||||
|
if count == 0 {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
(xlib.XNextEvent)(self.display.display, &mut xev);
|
||||||
|
}
|
||||||
|
self.process_event(&mut xev, &mut callback);
|
||||||
|
if self.interrupted.load(::std::sync::atomic::Ordering::Relaxed) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
(xlib.XNextEvent)(self.display.display, &mut xev);
|
|
||||||
}
|
}
|
||||||
self.process_event(&mut xev, &mut callback);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_forever<F>(&self, mut callback: F)
|
pub fn run_forever<F>(&self, mut callback: F)
|
||||||
|
|||||||
Reference in New Issue
Block a user