From 1887d8ef6acff107adb7b45c77028b1d63708106 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Wed, 15 Nov 2023 14:06:41 -0800 Subject: [PATCH] Add a `should_exit` method to `Application` trait A Cosmic application has no way to call `Cosmic::close` to set the `should_exit` flag there, as far as I'm aware. So it makes sense to add a `should_exit` method here. --- src/app/cosmic.rs | 2 +- src/app/mod.rs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/app/cosmic.rs b/src/app/cosmic.rs index 0b504a53..040bf167 100644 --- a/src/app/cosmic.rs +++ b/src/app/cosmic.rs @@ -104,7 +104,7 @@ where #[cfg(feature = "wayland")] fn should_exit(&self) -> bool { - self.should_exit + self.should_exit || self.app.should_exit() } fn style(&self) -> ::Style { diff --git a/src/app/mod.rs b/src/app/mod.rs index 01b7a59d..97f017d2 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -168,6 +168,11 @@ where /// Called before closing the application. fn on_app_exit(&mut self) {} + #[cfg(feature = "wayland")] + fn should_exit(&self) -> bool { + false + } + /// Called when a window requests to be closed. fn on_close_requested(&self, id: window::Id) -> Option { None