Restore the session on login: reopen the windows the last session ended with
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:
Claude committed 2026-11-25 18:31:31 +00:00
1 parent f7f90e1c41
commit 46780c399b
10 files changed
+435 -2

No files matched your search

+8
View File
@@ -49,6 +49,7 @@ pub fn run(args : Array[String]) -> Int {
let mut serve = false
let mut profile = false
let mut drm = false
let mut restore = true
let mut width = 1280
let mut height = 720
@@ -67,6 +68,9 @@ pub fn run(args : Array[String]) -> Int {
} else if a == "--drm" {
drm = true
i = i + 1
} else if a == "--no-restore" {
restore = false // don't reopen the apps of the last session
i = i + 1
} else if a == "--profile" {
profile = true
i = i + 1
@@ -171,6 +175,9 @@ pub fn run(args : Array[String]) -> Int {
None => ()
}
@sys.log("chandra compositor listening on " + socket_path)
if restore {
ignore(comp.restore_session()) // reopen the windows the last session ended with
}
let mut frames = 0
// A changed frame waits here until the display can take it (no page flip in flight).
let mut need_present = true
@@ -311,6 +318,7 @@ pub fn run(args : Array[String]) -> Int {
let spent = (@sys.monotonic_ms() - f0).to_int()
@sys.sleep_ms(if spent >= 16 { 1 } else { 16 - spent })
}
comp.save_session() // what is open now is reopened at the next start
match kms {
Some(k) => k.close()
None => ()