Retain tray service shutdown handle

This commit is contained in:
2026-09-12 11:59:36 +02:00
parent 53369904b4
commit f6c7f16c67
2 changed files with 17 additions and 2 deletions

View File

@@ -71,6 +71,10 @@ Each bounded iteration must:
- [x] Add migration coverage and recovery behavior for schema failures (failed migration rolls back its version marker and a repaired schema retries successfully; 18 tests and Docker build, 2026-09-10).
- [x] Test persistence, trimming, pinning, deletion, and missing-row mutation failure paths (20 tests and Docker build, 2026-09-10).
- [ ] Confirm startup cleanup and shutdown cleanup under crashes and interrupted runs.
- [x] Retain a tray shutdown handle and stop the ksni service during normal
application teardown (20 tests and Docker GTK/X11/package build, 2026-09-12).
- [ ] Add interruptible shutdown/join handling for X11 clipboard and hotkey
event workers; do not regress to a blocking GTK-thread polling loop.
- [x] Join the instance listener, bound incomplete client reads, and remove its socket during normal guard shutdown (19 tests and Docker GTK/X11 build, 2026-09-10).

View File

@@ -4,6 +4,16 @@ use crate::lifecycle::InstanceGuard;
struct ClipbhoardTray;
pub struct TrayHandle {
handle: ksni::Handle<ClipbhoardTray>,
}
impl Drop for TrayHandle {
fn drop(&mut self) {
self.handle.shutdown();
}
}
impl ksni::Tray for ClipbhoardTray {
fn id(&self) -> String {
"clipbhoard".into()
@@ -39,11 +49,12 @@ impl ksni::Tray for ClipbhoardTray {
}
}
pub fn start() -> Result<()> {
pub fn start() -> Result<TrayHandle> {
if std::env::var_os("DBUS_SESSION_BUS_ADDRESS").is_none() {
bail!("no D-Bus session bus is available")
}
let service = ksni::TrayService::new(ClipbhoardTray);
let handle = service.handle();
std::thread::Builder::new()
.name("clipbhoard-tray".into())
.spawn(move || {
@@ -51,5 +62,5 @@ pub fn start() -> Result<()> {
tracing::warn!(%error, "system tray service stopped");
}
})?;
Ok(())
Ok(TrayHandle { handle })
}