mirror of
https://github.com/Dasemu/Grove.git
synced 2026-11-26 15:26:09 +00:00
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:
4 files changed
+112
-16
No files matched your search
@@ -336,6 +336,16 @@ pub fn group_name(entry: &str) -> &str {
|
||||
entry.split(" → ").next().unwrap_or(entry)
|
||||
}
|
||||
|
||||
/// After a `--hidden` start (autostart at login), show requests from other launches are ignored
|
||||
/// for this long: they come from the desktop's session restore, and a window mapped while the
|
||||
/// compositor is still starting shows up in the task bar but never on screen.
|
||||
pub const LOGIN_GRACE: std::time::Duration = std::time::Duration::from_secs(20);
|
||||
|
||||
/// Whether a show request from another launch, `since_start` after this one started, is honoured.
|
||||
pub fn accept_instance_show(hidden_start: bool, since_start: std::time::Duration) -> bool {
|
||||
!hidden_start || since_start >= LOGIN_GRACE
|
||||
}
|
||||
|
||||
/// What the "Add or change a namespace" form holds.
|
||||
pub struct GroupForm {
|
||||
pub name: String,
|
||||
@@ -549,6 +559,15 @@ mod tests {
|
||||
assert_eq!(group_name("work → gitea"), "work");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn early_show_requests_are_ignored_only_after_a_hidden_start() {
|
||||
use std::time::Duration;
|
||||
assert!(accept_instance_show(false, Duration::ZERO));
|
||||
assert!(!accept_instance_show(true, Duration::from_secs(3)));
|
||||
assert!(accept_instance_show(true, LOGIN_GRACE));
|
||||
assert!(accept_instance_show(true, Duration::from_secs(600)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn group_form_becomes_group_add_args() {
|
||||
let mut f = GroupForm {
|
||||
|
||||
Reference in new issue
Block a user