diff --git a/src/event_loop/run.rs b/src/event_loop/run.rs index 406be74..edc99c1 100644 --- a/src/event_loop/run.rs +++ b/src/event_loop/run.rs @@ -383,6 +383,24 @@ pub( crate ) fn try_run( app: A ) -> Result<(), RunError> data.exit_requested = true; continue; } + Err( calloop::Error::OtherError( ref e ) ) => + { + // wayland-client surfaces the closed-socket condition as an + // OtherError wrapping an IoError rather than as the + // calloop::Error::IoError variant handled above. Treat any + // BrokenPipe / ConnectionReset here the same way: exit cleanly. + let is_closed = e.downcast_ref::() + .map( |io| matches!( io.kind(), + std::io::ErrorKind::BrokenPipe | std::io::ErrorKind::ConnectionReset ) ) + .unwrap_or( false ); + if is_closed + { + eprintln!( "ltk: wayland connection lost; exiting" ); + data.exit_requested = true; + continue; + } + panic!( "dispatch: {e:?}" ); + } Err( e ) => panic!( "dispatch: {e:?}" ), } // Any surface whose press has now crossed `long_press_duration`