Keep tray service alive across handle clones
This commit is contained in:
@@ -89,6 +89,7 @@ Each bounded iteration must:
|
||||
- [ ] Verify tray activation/menu behavior and graceful tray unavailability.
|
||||
- [x] Make the global shortcut and second-instance show request toggle the popup reliably without a delayed focus result reopening it (28 X11-feature tests and Docker GTK/X11/package build, 2026-09-12); live GUI acceptance remains pending.
|
||||
- [x] Use a standard theme icon for the live tray service so development runs do not depend on the custom icon being installed (Docker GTK/X11/package build, 2026-09-12); live tray acceptance remains pending.
|
||||
- [x] Keep cloned tray handles from shutting down the shared D-Bus service prematurely by making shutdown ownership reference-counted (D-Bus audit found the previous service disappeared after GTK activation; 28 tests and Docker GTK/X11/package build, 2026-09-12); live tray acceptance remains pending.
|
||||
- [x] Make `--diagnostics` inspect the running installation without triggering a
|
||||
show request, and report the log directory plus instance state (20 tests and
|
||||
Docker GTK/X11/package build, 2026-09-12).
|
||||
|
||||
16
src/tray.rs
16
src/tray.rs
@@ -11,17 +11,21 @@ struct CliphoardTray {
|
||||
recording: Arc<AtomicBool>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct TrayHandle {
|
||||
struct TrayOwner {
|
||||
handle: ksni::Handle<CliphoardTray>,
|
||||
}
|
||||
|
||||
impl Drop for TrayHandle {
|
||||
impl Drop for TrayOwner {
|
||||
fn drop(&mut self) {
|
||||
self.handle.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct TrayHandle {
|
||||
owner: Arc<TrayOwner>,
|
||||
}
|
||||
|
||||
impl ksni::Tray for CliphoardTray {
|
||||
fn id(&self) -> String {
|
||||
"cliphoard".into()
|
||||
@@ -63,7 +67,7 @@ impl ksni::Tray for CliphoardTray {
|
||||
|
||||
impl TrayHandle {
|
||||
pub fn set_recording(&self, recording: bool) {
|
||||
self.handle.update(|tray| {
|
||||
self.owner.handle.update(|tray| {
|
||||
tray.recording.store(recording, Ordering::Release);
|
||||
});
|
||||
}
|
||||
@@ -82,5 +86,7 @@ pub fn start(recording: Arc<AtomicBool>) -> Result<TrayHandle> {
|
||||
tracing::warn!(%error, "system tray service stopped");
|
||||
}
|
||||
})?;
|
||||
Ok(TrayHandle { handle })
|
||||
Ok(TrayHandle {
|
||||
owner: Arc::new(TrayOwner { handle }),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user