From a4ab7dc64c4efd9f4730908937dd109d76154deb Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Mon, 17 Mar 2025 13:20:17 +0300 Subject: [PATCH] x11:wayland: fix pump_events blocking with `Wait` Using `Duration::Zero` with `Wait` polling mode was still blocking until the event was actually delivered. Thus when `pump_events` API is used, ensure that it's not happening. Fixes #4130. --- src/changelog/unreleased.md | 1 + src/platform_impl/linux/wayland/event_loop/mod.rs | 5 ++++- src/platform_impl/linux/x11/mod.rs | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/changelog/unreleased.md b/src/changelog/unreleased.md index af998577..792e5759 100644 --- a/src/changelog/unreleased.md +++ b/src/changelog/unreleased.md @@ -240,3 +240,4 @@ changelog entry. - On macOS, fixed redundant `SurfaceResized` event at window creation. - On Windows, fixed ~500 ms pause when clicking the title bar during continuous redraw. - On macos, `WindowExtMacOS::set_simple_fullscreen` now honors `WindowExtMacOS::set_borderless_game` +- On X11 and Wayland, fixed pump_events with `Some(Duration::Zero)` blocking with `Wait` polling mode diff --git a/src/platform_impl/linux/wayland/event_loop/mod.rs b/src/platform_impl/linux/wayland/event_loop/mod.rs index 8024df16..4e640eeb 100644 --- a/src/platform_impl/linux/wayland/event_loop/mod.rs +++ b/src/platform_impl/linux/wayland/event_loop/mod.rs @@ -272,7 +272,10 @@ impl EventLoop { // Reduce spurious wake-ups. let dispatched_events = self.with_state(|state| state.dispatched_events); - if matches!(cause, StartCause::WaitCancelled { .. }) && !dispatched_events { + if matches!(cause, StartCause::WaitCancelled { .. }) + && !dispatched_events + && timeout.is_none() + { continue; } diff --git a/src/platform_impl/linux/x11/mod.rs b/src/platform_impl/linux/x11/mod.rs index 44c68e8e..9a92b1fd 100644 --- a/src/platform_impl/linux/x11/mod.rs +++ b/src/platform_impl/linux/x11/mod.rs @@ -568,6 +568,7 @@ impl EventLoop { // If we don't have any pending `_receiver` if !self.has_pending() && !matches!(&cause, StartCause::ResumeTimeReached { .. } | StartCause::Poll) + && timeout.is_none() { return; }