From 83910ff5b0b09d8e637d26de02a25fc70d2f7825 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Wed, 13 Nov 2024 18:43:31 -0500 Subject: [PATCH] refactor: allow apps to request to be treated as a daemon --- core/src/settings.rs | 5 +++++ winit/src/lib.rs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/core/src/settings.rs b/core/src/settings.rs index e3eb433a..be744b36 100644 --- a/core/src/settings.rs +++ b/core/src/settings.rs @@ -43,6 +43,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 { @@ -55,6 +58,7 @@ impl Default for Settings { default_text_size: Pixels(14.0), antialiasing: false, exit_on_close_request: false, + is_daemon: false, } } } @@ -65,6 +69,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/lib.rs b/winit/src/lib.rs index 05abcce8..5f5fcfa4 100644 --- a/winit/src/lib.rs +++ b/winit/src/lib.rs @@ -123,7 +123,7 @@ where }; let (program, task) = runtime.enter(|| program::Instance::new(program)); - let is_daemon = window_settings.is_none(); + let is_daemon = settings.is_daemon || window_settings.is_none(); let task = if let Some(window_settings) = window_settings { let mut task = Some(task);