Session settings panel module: switch session restore and window placement on or off
CI / test (push) Failing after 16s
CI / test (push) Failing after 16s
- New 'session-settings' capability (wit/capabilities.wit: settings, is-on, set-setting) and 'session-settings' panel module: a "Session" button whose popup lists the session settings, each with an on/off switch. Clicking a row flips it at once (the list stays open); Up/Down move the highlight, Enter or Space flips it, Escape or a click elsewhere closes. In the default panel, between Wallpaper and Log out. - Two settings to start with, kept in state.edn and written only when off (absent means on): "Reopen windows at login" (:restore-session, the key session restore already read) and "Remember window positions" (:remember-windows; when off, floating windows aren't placed where their app was left and new places aren't recorded, but the saved ones are kept). - Served by both hosts: wasmer stub (native; settings table 6, bit mask in host int 3, requests 10/11) and host-wasm (publish-session-settings, set-session-setting request). - Tests: native end-to-end (open, click both rows, keyboard, Escape), a state.edn round trip that checks both settings take effect, and a host-wasm module test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hgxf6exeYrDGcy4WW3
This commit is contained in:
32 files changed
+1192
-44
No files matched your search
@@ -11,7 +11,8 @@
|
||||
|
||||
///| Modules loaded into a fresh panel, in order. `tasks` stretches, so what follows it packs right.
|
||||
let default_panel : Array[String] = [
|
||||
"launcher", "inspector", "layout", "tasks", "moon-disc", "clock-digital12", "wallpaper", "logout",
|
||||
"launcher", "inspector", "layout", "tasks", "moon-disc", "clock-digital12", "wallpaper", "session-settings",
|
||||
"logout",
|
||||
]
|
||||
|
||||
///| The module whose popup is the wasm picker.
|
||||
@@ -391,6 +392,15 @@ fn DesktopShell::publish_host_data(self : DesktopShell) -> Unit {
|
||||
@wasm.publish(Wallpapers, pt)
|
||||
@wasm.publish_wallpaper(self.wallpaper_sel)
|
||||
}
|
||||
if self.widgets.iter().any(w => w.has_cap("session-settings")) {
|
||||
let st = @wasm.Table::new()
|
||||
for n in session_setting_names {
|
||||
st.str(n)
|
||||
st.end_row()
|
||||
}
|
||||
@wasm.publish(SessionSettings, st)
|
||||
@wasm.publish_session_settings(self.session_settings_bits())
|
||||
}
|
||||
let it = @wasm.Table::new()
|
||||
for w in self.widgets {
|
||||
it.str(w.slot)
|
||||
@@ -435,6 +445,25 @@ pub fn DesktopShell::set_wallpaper(self : DesktopShell, i : Int) -> Unit {
|
||||
self.save_state()
|
||||
}
|
||||
|
||||
///| The session settings the session settings module lists, in index order.
|
||||
let session_setting_names : Array[String] = ["Reopen windows at login", "Remember window positions"]
|
||||
|
||||
///| Which session settings are on: bit i for `session_setting_names[i]`.
|
||||
fn DesktopShell::session_settings_bits(self : DesktopShell) -> Int {
|
||||
(if self.restore_session { 1 } else { 0 }) | (if self.remember_windows { 2 } else { 0 })
|
||||
}
|
||||
|
||||
///| Turn session setting `i` on or off (ignored when out of range) and remember it in state.edn.
|
||||
pub fn DesktopShell::set_session_setting(self : DesktopShell, i : Int, on : Bool) -> Unit {
|
||||
match i {
|
||||
0 => self.restore_session = on
|
||||
1 => self.remember_windows = on
|
||||
_ => return
|
||||
}
|
||||
@wasm.publish_session_settings(self.session_settings_bits())
|
||||
self.save_state()
|
||||
}
|
||||
|
||||
///| Carry out what modules asked of the host during their last calls.
|
||||
fn DesktopShell::process_requests(self : DesktopShell) -> Unit {
|
||||
while true {
|
||||
@@ -456,6 +485,7 @@ fn DesktopShell::process_requests(self : DesktopShell) -> Unit {
|
||||
Some(SetLayout(m)) => self.actions.push(SetLayout(m))
|
||||
Some(Logout) => self.actions.push(Logout)
|
||||
Some(SetWallpaper(i)) => self.set_wallpaper(i)
|
||||
Some(SetSessionSetting(i, on)) => self.set_session_setting(i, on)
|
||||
Some(SetInspector(on)) => self.set_inspecting(on)
|
||||
Some(LoadModule(path)) => {
|
||||
match self.load_path(path) {
|
||||
|
||||
Reference in new issue
Block a user