fix(event_loop): exit cleanly on OtherError(BrokenPipe) from compositor

calloop surfaces the closed-socket condition either as
Error::IoError(BrokenPipe) — already handled — or as
Error::OtherError wrapping an std::io::Error with kind BrokenPipe,
which previously fell through to panic!(). Add a matching arm that
downcasts the inner error and treats both forms the same: log and
set exit_requested so the run loop terminates gracefully instead
of unwinding.
This commit is contained in:
yamabush1
2026-05-17 18:28:50 +02:00
parent 4a80165428
commit 750eae7a93

View File

@@ -383,6 +383,24 @@ pub( crate ) fn try_run<A: App>( 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::<std::io::Error>()
.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`