Settings module: the wallpaper chooser moves in, and a Dark mode switch
CI / test (push) Failing after 16s

- The session settings module becomes the panel's "Settings" button. Its popup lists the session
  switches, then a "Wallpaper" heading and the wallpapers (current one ticked); a click on a
  wallpaper shows it at once, as the old chooser did. Up/Down skip the heading.
- The standalone wallpaper module and its world are removed. A saved panel.edn that lists
  "wallpaper" gets the settings module in its place (or just drops it when Settings is there).
- New "Dark mode" setting (on by default). Off swaps the compositor to the Moon Day palette
  (ThemeTokens::moon_day, the values of config/themes/moon-day.json) for the shell, panel modules,
  window decorations and the switcher; on goes back to the configured theme. Saved in state.edn
  as :theme :light (absent or :dark: dark) and applied at startup by restore_state.
- Tests: the native wallpaper test drives the settings module, the settings test flips Dark mode
  and checks the theme, the state.edn round trip covers :theme, panel migration unit test, and
  the host-wasm test covers the switches and the wallpaper rows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hgxf6exeYrDGcy4WW3
This commit is contained in:
Claude committed 2026-11-25 18:46:25 +00:00
1 parent a0b878af23
commit ee019ecbaa
26 files changed
+295 -878

No files matched your search

+37 -5
View File
@@ -11,8 +11,7 @@
///| 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", "session-settings",
"logout",
"launcher", "inspector", "layout", "tasks", "moon-disc", "clock-digital12", "session-settings", "logout",
]
///| The module whose popup is the wasm picker.
@@ -172,6 +171,30 @@ fn wall_secs() -> Int {
@sys.wall_time_field(3) * 3600 + @sys.wall_time_field(4) * 60 + @sys.wall_time_field(5)
}
///| Panels saved before the wallpaper chooser moved into the settings module list "wallpaper":
/// the settings module takes its place (once; a panel that already has it just drops it).
fn migrate_panel(entries : Array[String]) -> Array[String] {
let has_settings = entries.contains("session-settings")
let out : Array[String] = []
for e in entries {
if e == "wallpaper" {
if !has_settings && !out.contains("session-settings") {
out.push("session-settings")
}
} else {
out.push(e)
}
}
out
}
///|
test "a saved panel's wallpaper button becomes the settings module" {
assert_eq(migrate_panel(["launcher", "wallpaper", "logout"]), ["launcher", "session-settings", "logout"])
assert_eq(migrate_panel(["wallpaper", "session-settings"]), ["session-settings"])
assert_eq(migrate_panel(["clock"]), ["clock"])
}
///| Load the panel on first use: the saved layout if there is one, else the default modules.
fn DesktopShell::ensure_booted(self : DesktopShell) -> Unit {
if self.booted {
@@ -180,7 +203,7 @@ fn DesktopShell::ensure_booted(self : DesktopShell) -> Unit {
self.booted = true
self.scan_catalog()
let entries = match self.load_panel_config() {
Some(e) => e
Some(e) => migrate_panel(e)
None => default_panel
}
for e in entries {
@@ -446,11 +469,15 @@ pub fn DesktopShell::set_wallpaper(self : DesktopShell, i : Int) -> Unit {
}
///| The session settings the session settings module lists, in index order.
let session_setting_names : Array[String] = ["Reopen windows at login", "Remember window positions"]
let session_setting_names : Array[String] = [
"Reopen windows at login", "Remember window positions", "Dark mode",
]
///| 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 })
(if self.restore_session { 1 } else { 0 }) |
(if self.remember_windows { 2 } else { 0 }) |
(if self.dark_mode { 4 } else { 0 })
}
///| Turn session setting `i` on or off (ignored when out of range) and remember it in state.edn.
@@ -458,6 +485,11 @@ pub fn DesktopShell::set_session_setting(self : DesktopShell, i : Int, on : Bool
match i {
0 => self.restore_session = on
1 => self.remember_windows = on
2 =>
if self.dark_mode != on {
self.dark_mode = on
self.actions.push(ThemeChanged)
}
_ => return
}
@wasm.publish_session_settings(self.session_settings_bits())