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

+5
View File
@@ -139,6 +139,8 @@ pub(all) enum ShellAction {
FocusWindow(UInt64)
/// A module (the logout button) asked to end the session.
Logout
/// The Dark mode setting changed: the compositor swaps the theme (see `dark_mode`).
ThemeChanged
} derive(Eq, Debug)
///| One wasm module loaded into the panel.
@@ -206,6 +208,8 @@ pub(all) struct DesktopShell {
/// last session's windows at the next start, and remember where floating windows were left.
mut restore_session : Bool
mut remember_windows : Bool
/// Dark mode (the configured theme) or light (Moon Day); saved as `:theme :light` when off.
mut dark_mode : Bool
mut desk_set : Bool
mut desk_x : Int
mut desk_y : Int
@@ -292,6 +296,7 @@ pub fn DesktopShell::new(display : String) -> DesktopShell {
wallpaper_sel: 0,
restore_session: true,
remember_windows: true,
dark_mode: true,
desk_set: false,
desk_x: 0,
desk_y: 0,
+18 -1
View File
@@ -5,7 +5,8 @@
/// :recent ["foot" "dolphin"] ; the launcher's recently started apps, newest first
/// :windows {"foot" {:x 80 :y 60 :w 640 :h 480}} ; floating windows' last place, by app id
/// :desktop-card {:x 900 :y 24} ; where the desktop card was dragged to (absent: default spot)
/// :wallpaper :aurora ; the wallpaper module's choice (absent: :plasma-glow)
/// :wallpaper :aurora ; the settings module's wallpaper (absent: :plasma-glow)
/// :theme :light ; the settings module's Dark mode switch is off (absent: dark)
/// :session [{:app "foot"} {:app "org.gnome.Nautilus" :minimized true}]
/// ; the windows open when the last session ended, reopened at
/// ; the next start (see session.mbt in compositor/host)
@@ -31,6 +32,8 @@ pub(all) struct SavedState {
/// Session settings; None when the file doesn't say (both default to on).
restore_session : Bool?
remember_windows : Bool?
/// From `:theme`: true for :dark, false for :light.
dark_mode : Bool?
}
///|
@@ -44,6 +47,7 @@ let layout_names : Array[String] = ["tiling", "monocle", "floating"]
///| The keys this build owns; everything else in the file is kept as it is.
let owned_keys : Array[String] = [
"layout", "recent", "desktop-card", "windows", "wallpaper", "restore-session", "remember-windows",
"theme",
]
///| How state.edn names each wallpaper, in `@libshell.wallpaper_names` order.
@@ -87,6 +91,7 @@ pub fn DesktopShell::load_state(self : DesktopShell) -> SavedState {
wallpaper: None,
restore_session: None,
remember_windows: None,
dark_mode: None,
}
}
let entries = read_state_file()
@@ -186,6 +191,11 @@ pub fn DesktopShell::load_state(self : DesktopShell) -> SavedState {
wallpaper,
restore_session: flag("restore-session"),
remember_windows: flag("remember-windows"),
dark_mode: match lookup_key(entries, "theme") {
Some(Keyword("light")) => Some(false)
Some(Keyword("dark")) => Some(true)
_ => None
},
}
}
@@ -206,6 +216,10 @@ pub fn DesktopShell::apply_state(self : DesktopShell, st : SavedState) -> Unit {
Some(b) => self.remember_windows = b
None => ()
}
match st.dark_mode {
Some(b) => self.dark_mode = b
None => ()
}
match st.desk {
Some((x, y)) => {
self.desk_set = true
@@ -278,6 +292,9 @@ pub fn DesktopShell::save_state(self : DesktopShell) -> Unit {
entries.insert(2, (@edn.Value::Keyword("wallpaper"), @edn.Value::Keyword(wallpaper_keys[self.wallpaper_sel])))
}
// Session settings are written only when off: absent means on, as for a hand-written file.
if !self.dark_mode {
entries.insert(2, (@edn.Value::Keyword("theme"), @edn.Value::Keyword("light")))
}
if !self.remember_windows {
entries.insert(2, (@edn.Value::Keyword("remember-windows"), @edn.Value::Bool(false)))
}
+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())