From c6cfa048b0157c1f0b8c7ba976ff969f8f7a86e7 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 587863045..a75ff6941 100644 --- a/src/changelog/unreleased.md +++ b/src/changelog/unreleased.md @@ -48,3 +48,4 @@ changelog entry. - 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 f379841a6..b4c69b0f5 100644 --- a/src/platform_impl/linux/wayland/event_loop/mod.rs +++ b/src/platform_impl/linux/wayland/event_loop/mod.rs @@ -285,7 +285,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 4042da0d0..6d3f93115 100644 --- a/src/platform_impl/linux/x11/mod.rs +++ b/src/platform_impl/linux/x11/mod.rs @@ -497,6 +497,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; }