From cc4a2dc2a2ef1249e7fdfd005fd2bb2ae31fc397 Mon Sep 17 00:00:00 2001 From: Ferdinand Bachmann Date: Mon, 25 Nov 2024 17:04:53 +0100 Subject: [PATCH] Fix swayosd-server exiting when no monitors exist (e.g. on switch to another tty) The GApplication exits when no monitors exist. Counteract this by always keeping a reference to the GApplication, which avoids this. Since swayosd-server is a daemon, the normal behaviour of exiting after the last window is gone is unwanted. --- src/server/application.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/server/application.rs b/src/server/application.rs index 8afaaad..e7c08ca 100644 --- a/src/server/application.rs +++ b/src/server/application.rs @@ -27,11 +27,13 @@ pub struct SwayOSDApplication { #[shrinkwrap(main_field)] app: gtk::Application, windows: Rc>>, + _hold: Rc, } impl SwayOSDApplication { pub fn new(server_config: ServerConfig, action_receiver: Receiver<(ArgTypes, String)>) -> Self { let app = Application::new(Some(APPLICATION_NAME), ApplicationFlags::FLAGS_NONE); + let hold = Rc::new(app.hold()); app.add_main_option( "config", @@ -66,6 +68,7 @@ impl SwayOSDApplication { let osd_app = SwayOSDApplication { app: app.clone(), windows: Rc::new(RefCell::new(Vec::new())), + _hold: hold, }; // Apply Server Config