refactor: add is_daemon setting
The app can request to be treated by iced as a daemon so it can perform cleanup when its main window is closed.
This commit is contained in:
parent
e3fabf7d12
commit
aaadf7199e
4 changed files with 9 additions and 4 deletions
2
iced
2
iced
|
|
@ -1 +1 @@
|
||||||
Subproject commit d0c2a0371b476866cb0f7045fba0215425493d62
|
Subproject commit 256863574bacfb1d2797c2a48cba7a3388cbeb59
|
||||||
|
|
@ -160,7 +160,7 @@ where
|
||||||
return Some(Message::WindowResize(id, width, height));
|
return Some(Message::WindowResize(id, width, height));
|
||||||
}
|
}
|
||||||
iced::Event::Window(window::Event::Closed) => {
|
iced::Event::Window(window::Event::Closed) => {
|
||||||
return Some(Message::SurfaceClosed(id))
|
return Some(Message::SurfaceClosed(id));
|
||||||
}
|
}
|
||||||
iced::Event::Window(window::Event::Focused) => return Some(Message::Focus(id)),
|
iced::Event::Window(window::Event::Focused) => return Some(Message::Focus(id)),
|
||||||
iced::Event::Window(window::Event::Unfocused) => return Some(Message::Unfocus(id)),
|
iced::Event::Window(window::Event::Unfocused) => return Some(Message::Unfocus(id)),
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,8 @@ pub(crate) fn iced_settings<App: Application>(
|
||||||
iced.default_font = settings.default_font;
|
iced.default_font = settings.default_font;
|
||||||
iced.default_text_size = iced::Pixels(settings.default_text_size);
|
iced.default_text_size = iced::Pixels(settings.default_text_size);
|
||||||
let exit_on_close = settings.exit_on_close;
|
let exit_on_close = settings.exit_on_close;
|
||||||
iced.exit_on_close_request = exit_on_close;
|
iced.is_daemon = false;
|
||||||
|
iced.exit_on_close_request = settings.is_daemon;
|
||||||
let mut window_settings = iced::window::Settings::default();
|
let mut window_settings = iced::window::Settings::default();
|
||||||
window_settings.exit_on_close_request = exit_on_close;
|
window_settings.exit_on_close_request = exit_on_close;
|
||||||
iced.id = Some(App::APP_ID.to_owned());
|
iced.id = Some(App::APP_ID.to_owned());
|
||||||
|
|
|
||||||
|
|
@ -57,8 +57,11 @@ pub struct Settings {
|
||||||
/// Whether the window should be transparent.
|
/// Whether the window should be transparent.
|
||||||
pub(crate) transparent: bool,
|
pub(crate) transparent: bool,
|
||||||
|
|
||||||
/// Whether the application should exit when there are no open windows
|
/// Whether the application window should close when the exit button is pressed
|
||||||
pub(crate) exit_on_close: bool,
|
pub(crate) exit_on_close: bool,
|
||||||
|
|
||||||
|
/// Whether the application should act as a daemon
|
||||||
|
pub(crate) is_daemon: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Settings {
|
impl Settings {
|
||||||
|
|
@ -92,6 +95,7 @@ impl Default for Settings {
|
||||||
theme: crate::theme::system_preference(),
|
theme: crate::theme::system_preference(),
|
||||||
transparent: true,
|
transparent: true,
|
||||||
exit_on_close: true,
|
exit_on_close: true,
|
||||||
|
is_daemon: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue