Settings module: the wallpaper chooser moves in, and a Dark mode switch
CI / test (push) Failing after 16s
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:
26 files changed
+295
-878
No files matched your search
+30
-49
@@ -595,30 +595,46 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn wallpaper_module_lists_the_wallpapers_and_requests_a_switch() {
|
||||
fn settings_module_shows_switches_and_wallpapers_and_requests_changes() {
|
||||
let mut rt = runtime();
|
||||
let l = rt.load(&module("wallpaper")).expect("wallpaper loads");
|
||||
assert!(l.imports.contains(&"wallpaper".to_string()));
|
||||
let l = rt.load(&module("session-settings")).expect("session-settings loads");
|
||||
assert!(l.imports.contains(&"session-settings".to_string()));
|
||||
let h = l.handle;
|
||||
let names = ["Plasma glow", "Aurora", "Starfield"];
|
||||
let mut t = (names.len() as u32).to_le_bytes().to_vec();
|
||||
for n in names {
|
||||
t.extend((n.len() as u32).to_le_bytes());
|
||||
t.extend(n.as_bytes());
|
||||
}
|
||||
rt.shared.borrow_mut().tables[T_WALLPAPERS] = t;
|
||||
assert!(l.imports.contains(&"wallpaper".to_string()));
|
||||
let table = |names: &[&str]| {
|
||||
let mut t = (names.len() as u32).to_le_bytes().to_vec();
|
||||
for n in names {
|
||||
t.extend((n.len() as u32).to_le_bytes());
|
||||
t.extend(n.as_bytes());
|
||||
}
|
||||
t
|
||||
};
|
||||
let names = ["Reopen windows at login", "Remember window positions", "Dark mode"];
|
||||
let walls = ["Plasma glow", "Aurora", "Starfield"];
|
||||
rt.shared.borrow_mut().tables[T_SESSION_SETTINGS] = table(&names);
|
||||
rt.shared.borrow_mut().tables[T_WALLPAPERS] = table(&walls);
|
||||
rt.shared.borrow_mut().session_settings = 0b101; // reopen on, remember off, dark on
|
||||
rt.shared.borrow_mut().wallpaper = 1;
|
||||
assert!(texts(&rt.render(h, Size { w: 96, h: 34 })).contains(&"Wallpaper".to_string()));
|
||||
// A click opens the list of every wallpaper; nothing is requested yet.
|
||||
assert!(texts(&rt.render(h, Size { w: 92, h: 34 })).contains(&"Settings".to_string()));
|
||||
// A click opens the list of every setting; nothing is requested yet.
|
||||
assert!(rt.popup(h).is_none());
|
||||
assert!(rt.on_event(h, false, InputEvent::PointerDown(Point { x: 5, y: 5 })));
|
||||
let p = rt.popup(h).expect("popup open");
|
||||
for n in names {
|
||||
for n in names.iter().chain(walls.iter()).chain(["Wallpaper"].iter()) {
|
||||
assert!(texts(&p.ops).contains(&n.to_string()), "{n} listed");
|
||||
}
|
||||
assert!(rt.shared.borrow().requests.is_empty());
|
||||
// Third row: Starfield.
|
||||
// First row is on: a click asks to turn it off. Second row is off: a click asks for on.
|
||||
assert!(rt.on_event(h, true, InputEvent::PointerDown(Point { x: 20, y: 6 + 5 })));
|
||||
assert!(matches!(rt.shared.borrow_mut().requests.pop_front(), Some(Req::SetSessionSetting(0, false))));
|
||||
assert!(rt.on_event(h, true, InputEvent::PointerDown(Point { x: 20, y: 6 + 30 + 5 })));
|
||||
assert!(matches!(rt.shared.borrow_mut().requests.pop_front(), Some(Req::SetSessionSetting(1, true))));
|
||||
assert!(rt.on_event(h, true, InputEvent::PointerDown(Point { x: 20, y: 6 + 2 * 30 + 5 })));
|
||||
assert!(matches!(rt.shared.borrow_mut().requests.pop_front(), Some(Req::SetSessionSetting(2, false))));
|
||||
// Row 3 is the "Wallpaper" heading (nothing); rows 4.. are the wallpapers: Starfield.
|
||||
assert!(rt.on_event(h, true, InputEvent::PointerDown(Point { x: 20, y: 6 + 3 * 30 + 5 })));
|
||||
assert!(rt.shared.borrow().requests.is_empty());
|
||||
assert!(rt.on_event(h, true, InputEvent::PointerDown(Point { x: 20, y: 6 + 6 * 30 + 5 })));
|
||||
assert!(matches!(rt.shared.borrow_mut().requests.pop_front(), Some(Req::SetWallpaper(2))));
|
||||
// The list stays open; Escape closes it without another request.
|
||||
assert!(rt.popup(h).is_some());
|
||||
@@ -627,39 +643,4 @@ mod tests {
|
||||
assert!(rt.shared.borrow().requests.is_empty());
|
||||
rt.unload(h);
|
||||
}
|
||||
#[test]
|
||||
fn session_settings_module_shows_switches_and_requests_a_flip() {
|
||||
let mut rt = runtime();
|
||||
let l = rt.load(&module("session-settings")).expect("session-settings loads");
|
||||
assert!(l.imports.contains(&"session-settings".to_string()));
|
||||
let h = l.handle;
|
||||
let names = ["Reopen windows at login", "Remember window positions"];
|
||||
let mut t = (names.len() as u32).to_le_bytes().to_vec();
|
||||
for n in names {
|
||||
t.extend((n.len() as u32).to_le_bytes());
|
||||
t.extend(n.as_bytes());
|
||||
}
|
||||
rt.shared.borrow_mut().tables[T_SESSION_SETTINGS] = t;
|
||||
rt.shared.borrow_mut().session_settings = 0b01; // reopen on, remember off
|
||||
assert!(texts(&rt.render(h, Size { w: 86, h: 34 })).contains(&"Session".to_string()));
|
||||
// A click opens the list of every setting; nothing is requested yet.
|
||||
assert!(rt.popup(h).is_none());
|
||||
assert!(rt.on_event(h, false, InputEvent::PointerDown(Point { x: 5, y: 5 })));
|
||||
let p = rt.popup(h).expect("popup open");
|
||||
for n in names {
|
||||
assert!(texts(&p.ops).contains(&n.to_string()), "{n} listed");
|
||||
}
|
||||
assert!(rt.shared.borrow().requests.is_empty());
|
||||
// First row is on: a click asks to turn it off. Second row is off: a click asks for on.
|
||||
assert!(rt.on_event(h, true, InputEvent::PointerDown(Point { x: 20, y: 6 + 5 })));
|
||||
assert!(matches!(rt.shared.borrow_mut().requests.pop_front(), Some(Req::SetSessionSetting(0, false))));
|
||||
assert!(rt.on_event(h, true, InputEvent::PointerDown(Point { x: 20, y: 6 + 32 + 5 })));
|
||||
assert!(matches!(rt.shared.borrow_mut().requests.pop_front(), Some(Req::SetSessionSetting(1, true))));
|
||||
// The list stays open; Escape closes it without another request.
|
||||
assert!(rt.popup(h).is_some());
|
||||
assert!(rt.on_event(h, true, InputEvent::KeyDown("Escape".to_string())));
|
||||
assert!(rt.popup(h).is_none());
|
||||
assert!(rt.shared.borrow().requests.is_empty());
|
||||
rt.unload(h);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user