diff --git a/window/src/os/x11/connection.rs b/window/src/os/x11/connection.rs index 9f68bbd51..e539059c9 100644 --- a/window/src/os/x11/connection.rs +++ b/window/src/os/x11/connection.rs @@ -282,15 +282,9 @@ impl ConnectionOps for Connection { match poll.poll(&mut events, Some(period)) { Ok(_) => { - for event in &events { - let t = event.token(); - if t == tok_xcb { - self.process_queued_xcb()?; - } else if t == tok_spawn { - SPAWN_QUEUE.run(); - } else { - } - } + // We process both event sources unconditionally + // in the loop above anyway; we're just using + // this to get woken up. } Err(err) => { diff --git a/window/src/spawn.rs b/window/src/spawn.rs index 8c6f9de42..0f2ee6853 100644 --- a/window/src/spawn.rs +++ b/window/src/spawn.rs @@ -141,13 +141,21 @@ impl SpawnQueue { // On linux we only ever process one at at time, so that // we can return to the main loop and process messages // from the X server - use std::io::Read; if let Some(func) = self.pop_func() { func(); - - let mut byte = [0u8]; - self.read.lock().unwrap().read(&mut byte).ok(); } + + // try to drain the pipe. + // We do this regardless of whether we popped an item + // so that we avoid being in a perpetually signalled state. + // It is ok if we completely drain the pipe because the + // main loop uses the return value to set the sleep + // interval and will unconditionally call us on each + // iteration. + let mut byte = [0u8; 64]; + use std::io::Read; + self.read.lock().unwrap().read(&mut byte).ok(); + self.has_any_queued() } }