mirror of
https://github.com/danbulant/cushy
synced 2026-06-18 14:01:10 +00:00
App::prevent_shutdown()
This commit is contained in:
parent
8d082ab77f
commit
09790039af
4 changed files with 23 additions and 2 deletions
|
|
@ -140,6 +140,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
directly, including getting a reference to the underlying winit Window.
|
||||
- `Modal` is a new layer widget that presents a single widget as a modal
|
||||
session.
|
||||
- `App::prevent_shutdown()` returns a guard that prevents the application from
|
||||
closing automatically when the final window is closed.
|
||||
|
||||
|
||||
[139]: https://github.com/khonsulabs/cushy/issues/139
|
||||
|
|
|
|||
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -124,7 +124,7 @@ checksum = "4e1496f8fb1fbf272686b8d37f523dab3e4a7443300055e74cdaa449f3114356"
|
|||
[[package]]
|
||||
name = "appit"
|
||||
version = "0.3.2"
|
||||
source = "git+https://github.com/khonsulabs/appit#93479b81112dfeef2b1646c5050c9fbd305c3288"
|
||||
source = "git+https://github.com/khonsulabs/appit#331bfdd3534a2f6a7c44f24017b4d52aee40da5b"
|
||||
dependencies = [
|
||||
"winit",
|
||||
]
|
||||
|
|
|
|||
17
src/app.rs
17
src/app.rs
|
|
@ -352,8 +352,25 @@ impl App {
|
|||
pub fn monitors(&self) -> Option<Monitors> {
|
||||
self.app.as_ref().and_then(kludgine::app::App::monitors)
|
||||
}
|
||||
|
||||
/// Creates a guard that prevents this app from shutting down.
|
||||
///
|
||||
/// If the app is not currently running, this function returns None.
|
||||
///
|
||||
/// Once a guard is allocated the app will not be closed automatically when
|
||||
/// the final window is closed. If the final shutdown guard is dropped while
|
||||
/// no windows are open, the app will be closed.
|
||||
#[allow(clippy::missing_panics_doc, clippy::must_use_candidate)]
|
||||
pub fn prevent_shutdown(&self) -> Option<ShutdownGuard> {
|
||||
self.app
|
||||
.as_ref()
|
||||
.and_then(kludgine::app::App::prevent_shutdown)
|
||||
}
|
||||
}
|
||||
|
||||
/// A guard preventing an [`App`] from shutting down.
|
||||
pub type ShutdownGuard = kludgine::app::ShutdownGuard<WindowCommand>;
|
||||
|
||||
impl Application for App {
|
||||
fn cushy(&self) -> &Cushy {
|
||||
&self.cushy
|
||||
|
|
|
|||
|
|
@ -34,7 +34,9 @@ use std::ops::{Add, AddAssign, Sub, SubAssign};
|
|||
|
||||
#[cfg(feature = "tokio")]
|
||||
pub use app::TokioRuntime;
|
||||
pub use app::{App, AppRuntime, Application, Cushy, DefaultRuntime, Open, PendingApp, Run};
|
||||
pub use app::{
|
||||
App, AppRuntime, Application, Cushy, DefaultRuntime, Open, PendingApp, Run, ShutdownGuard,
|
||||
};
|
||||
/// A macro to create a `main()` function with less boilerplate.
|
||||
///
|
||||
/// When creating applications that support multiple windows, this attribute
|
||||
|
|
|
|||
Loading…
Reference in a new issue