From cd22b9bebe6e83bd186c6f1199aee699ef1e86ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20S=C3=A1lyi?= Date: Wed, 23 Apr 2025 22:19:12 +0200 Subject: [PATCH] Fix the way Wayland reads handle the WouldBlock error --- src/main.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 38f295f..5639f3d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -253,9 +253,20 @@ fn handle_wayland_event( event_queue: &mut EventQueue, read_guard: ReadEventsGuard, ) { - read_guard.read().expect("Failed to read Wayland events"); - event_queue.dispatch_pending(state) - .expect("Failed to dispatch pending Wayland events"); + match read_guard.read() { + Ok(_) => { + event_queue.dispatch_pending(state) + .expect("Failed to dispatch pending Wayland events"); + }, + Err(error) => { + if let WaylandError::Io(io_error) = &error { + if io_error.kind() == io::ErrorKind::WouldBlock { + return + } + } + panic!("Failed to read Wayland events: {error}"); + } + } } fn handle_sway_event(