Restore the session on login: reopen the windows the last session ended with
CI / test (push) Failing after 20s
CI / test (push) Failing after 20s
- state.edn gets :session [{:app "foot"} {:app "org.gnome.Nautilus" :minimized true}]: the open
windows by app id, in opening order, with whether each was minimized or maximized. Dialogs
(xdg_toplevel.set_parent, now tracked by the Wayland server) are left out.
- Written at the end of a session (logout, or the display/window going away) and, against
crashes, whenever the set of windows changes and then holds for 3 s; that delay also keeps a
shutdown, where apps die a moment before the compositor, from saving an empty desktop.
- At start (both the native binary and the wasm compositor) each saved app is launched through
its .desktop file: the app id is matched to the desktop file id, StartupWMClass (now parsed),
case-insensitively, or by its last dotted part. Restored apps don't count as recent launches.
A launched app stays in the session until its window shows up (30 s at most), and that window
gets its minimized/maximized state back; placement is the existing layout mode and per-app
floating geometry.
- --no-restore, or :restore-session false in state.edn, starts with an empty desktop.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hjkHnYqipToGkWFC9P
This commit is contained in:
10 files changed
+435
-2
No files matched your search
@@ -1210,3 +1210,46 @@ test "state saved by a build from before the rename to Chandra is still read" {
|
||||
@sys.unlink(dir + "/moon-plasma/state.edn")
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
test "the open windows are saved as the session and a restored app's window gets its state back" {
|
||||
if @sys.getenv("CHANDRA_TEST_CONFIG") == "1" {
|
||||
write_state_edn("{:note \"keep\"}\n")
|
||||
let sock1 = "/tmp/wayland-moon-ss1-" + @sys.getpid().to_string() + ".sock"
|
||||
let theme = @scene.ThemeTokens::moon_night()
|
||||
let a = @host.ChandraCompositor::new(sock1, theme, 1280, 720).unwrap()
|
||||
a.shell.persist = true
|
||||
ignore(open_and_configure_client(a, sock1, "A", "org.test.alpha"))
|
||||
ignore(open_and_configure_client(a, sock1, "B", "org.test.beta"))
|
||||
ignore(a.compose_frame())
|
||||
ignore(a.wm.handle_request(2UL, @wm.WindowRequest::Minimize(true), a.work_area))
|
||||
a.save_session()
|
||||
let text = read_state_edn()
|
||||
assert_true(text.contains(":session"))
|
||||
assert_true(text.contains("\"org.test.alpha\"") && text.contains("\"org.test.beta\""))
|
||||
assert_true(text.contains(":minimized true"))
|
||||
assert_true(text.contains(":note \"keep\""))
|
||||
// Saving the other state keeps the session, and the session reads back in order.
|
||||
a.shell.save_state()
|
||||
let saved = a.shell.load_session()
|
||||
assert_eq(saved.length(), 2)
|
||||
assert_eq(saved[0], { app: "org.test.alpha", minimized: false, maximized: false })
|
||||
assert_eq(saved[1], { app: "org.test.beta", minimized: true, maximized: false })
|
||||
// A new session: beta was launched and is waiting for its window. Until it shows up it still
|
||||
// counts as part of the session; when it opens it is minimized again.
|
||||
let sock2 = "/tmp/wayland-moon-ss2-" + @sys.getpid().to_string() + ".sock"
|
||||
let b = @host.ChandraCompositor::new(sock2, theme, 1280, 720).unwrap()
|
||||
b.shell.persist = true
|
||||
b.restore_pending.push(saved[1])
|
||||
b.restore_until = @sys.monotonic_ms() + 30000UL
|
||||
assert_eq(b.session_snapshot(@sys.monotonic_ms()), [saved[1]])
|
||||
ignore(open_and_configure_client(b, sock2, "B", "org.test.beta"))
|
||||
ignore(b.compose_frame())
|
||||
assert_eq(b.restore_pending.length(), 0)
|
||||
assert_true(b.wm.windows.get(1UL).unwrap().minimized)
|
||||
assert_eq(b.session_snapshot(@sys.monotonic_ms()), [saved[1]])
|
||||
// :restore-session false turns reopening off.
|
||||
write_state_edn("{:restore-session false :session [{:app \"foot\"}]}\n")
|
||||
assert_eq(b.shell.load_session().length(), 0)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user