diff --git a/src/program.rs b/src/program.rs index cb44eadb3f..464cc68bbc 100644 --- a/src/program.rs +++ b/src/program.rs @@ -191,6 +191,7 @@ pub trait Program: Sized { default_text_size: settings.default_text_size, antialiasing: settings.antialiasing, exit_on_close_request: settings.exit_on_close_request, + is_daemon: settings.exit_on_close_request, } .into(), renderer_settings, diff --git a/src/settings.rs b/src/settings.rs index 3b48ca1e31..77d0c0f4dd 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -35,6 +35,9 @@ pub struct Settings { /// If set to true the application will exit when the main window is closed. pub exit_on_close_request: bool, + + /// Whether the application is a daemon + pub is_daemon: bool, } impl Default for Settings { @@ -46,6 +49,7 @@ impl Default for Settings { default_text_size: Pixels(14.0), antialiasing: false, exit_on_close_request: false, + is_daemon: false, } } } @@ -56,6 +60,7 @@ impl From for iced_winit::Settings { iced_winit::Settings { id: settings.id, fonts: settings.fonts, + is_daemon: settings.is_daemon, } } } diff --git a/winit/src/program.rs b/winit/src/program.rs index 405f9ece4c..4ceb2d82da 100644 --- a/winit/src/program.rs +++ b/winit/src/program.rs @@ -193,7 +193,7 @@ where }; let (program, task) = runtime.enter(|| P::new(flags)); - let is_daemon = window_settings.is_none(); + let is_daemon = window_settings.is_none() || settings.is_daemon; let task = if let Some(window_settings) = window_settings { let mut task = Some(task); diff --git a/winit/src/settings.rs b/winit/src/settings.rs index 78368a04aa..8723c1f554 100644 --- a/winit/src/settings.rs +++ b/winit/src/settings.rs @@ -12,4 +12,7 @@ pub struct Settings { /// The fonts to load on boot. pub fonts: Vec>, + + /// Whether the application should exit when no windows are left + pub is_daemon: bool, }