fix(gui): keep an autostarted window from opening during login

On Plasma Wayland an autostarted grove-gui could end up with a task bar
entry that shows nothing (window mapped while the compositor starts).

- A --hidden start waits for the StatusNotifier watcher instead of opening
  the window when the tray is not up yet (ksni assume_sni_available)
- Show requests from other launches in the first 20 s after a --hidden start
  (session restore) are ignored and logged
- Every window show is logged with its reason; the session type at start

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011GZUAGhGYoiLvmfXweQnDY
This commit is contained in:
Claude committed 2026-11-25 14:35:02 +00:00
1 parent 31c8d5b4f7
commit 6b294e80d9
4 files changed
+112 -16

No files matched your search

+19 -2
View File
@@ -22,12 +22,18 @@ pub struct GroveTray {
pub type TrayHandle = Handle<GroveTray>;
/// Starts the tray service. Fails when there is no D-Bus session.
pub fn spawn(on_action: Arc<dyn Fn(Action) + Send + Sync>) -> Result<TrayHandle, ksni::Error> {
/// Starts the tray service. Fails when there is no D-Bus session. With `wait_for_host` a
/// missing StatusNotifier watcher/host is not an error: the item registers as soon as the
/// desktop's tray comes up (an autostarted app usually runs before Plasma's tray is ready).
pub fn spawn(
on_action: Arc<dyn Fn(Action) + Send + Sync>,
wait_for_host: bool,
) -> Result<TrayHandle, ksni::Error> {
GroveTray {
agg: Aggregate::default(),
on_action,
}
.assume_sni_available(wait_for_host)
.spawn()
}
@@ -48,6 +54,17 @@ impl ksni::Tray for GroveTray {
"grove".into()
}
fn watcher_online(&self) {
crate::log::line("tray: StatusNotifier watcher is online; icon registered");
}
fn watcher_offline(&self, reason: ksni::OfflineReason) -> bool {
crate::log::line(&format!(
"tray: StatusNotifier watcher offline ({reason:?}); waiting for it"
));
true
}
fn title(&self) -> String {
"Grove".into()
}