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
@@ -71,6 +71,16 @@ pub(all) struct ChandraCompositor {
|
||||
mut frame_changed : Bool
|
||||
mut prof_shell_ms : UInt64
|
||||
mut prof_raster_ms : UInt64
|
||||
/// Session restore (session.mbt): apps launched at start whose window hasn't appeared yet,
|
||||
/// until when they are waited for, and the windows that took their place.
|
||||
restore_pending : Array[@shell.SessionEntry]
|
||||
mut restore_until : UInt64
|
||||
restore_claimed : Map[UInt64, Bool]
|
||||
/// The session as last written, as last seen (and since when), and when to look again.
|
||||
mut session_saved : String
|
||||
mut session_seen : String
|
||||
mut session_seen_at : UInt64
|
||||
mut session_check_at : UInt64
|
||||
}
|
||||
|
||||
///|
|
||||
@@ -127,6 +137,13 @@ pub fn ChandraCompositor::new(
|
||||
frame_changed: true,
|
||||
prof_shell_ms: 0UL,
|
||||
prof_raster_ms: 0UL,
|
||||
restore_pending: [],
|
||||
restore_until: 0UL,
|
||||
restore_claimed: {},
|
||||
session_saved: "",
|
||||
session_seen: "",
|
||||
session_seen_at: 0UL,
|
||||
session_check_at: 0UL,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -306,12 +323,14 @@ pub fn ChandraCompositor::step(self : ChandraCompositor) -> Unit {
|
||||
}
|
||||
let actions = self.wm.open_window(rec, self.work_area)
|
||||
self.apply_actions(actions)
|
||||
self.claim_restored(wid, app_id)
|
||||
}
|
||||
@wayland.CompositorEvent::ToplevelUpdated(wid, app_id, title) =>
|
||||
match self.windows.get(wid) {
|
||||
Some(win) => {
|
||||
if app_id.length() > 0 {
|
||||
win.app_id = app_id
|
||||
self.claim_restored(wid, app_id)
|
||||
}
|
||||
if title.length() > 0 {
|
||||
win.title = title
|
||||
@@ -359,6 +378,7 @@ pub fn ChandraCompositor::step(self : ChandraCompositor) -> Unit {
|
||||
None => ()
|
||||
}
|
||||
ignore(self.windows.remove(wid))
|
||||
ignore(self.restore_claimed.remove(wid))
|
||||
if self.ptr_win == Some(wid) {
|
||||
self.ptr_win = None
|
||||
}
|
||||
@@ -395,6 +415,7 @@ pub fn ChandraCompositor::step(self : ChandraCompositor) -> Unit {
|
||||
@wayland.CompositorEvent::ToplevelMoveRequest(_) => ()
|
||||
}
|
||||
}
|
||||
self.session_tick()
|
||||
}
|
||||
|
||||
///|
|
||||
|
||||
Reference in new issue
Block a user