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
@@ -1134,23 +1134,28 @@ fn click_wallpaper_ops(comp : @host.ChandraCompositor, x : Int, y : Int, t : UIn
|
||||
}
|
||||
|
||||
///|
|
||||
test "the wallpaper module lists the wallpapers and switches the desktop to the one clicked" {
|
||||
test "the settings module lists the wallpapers and switches the desktop to the one clicked" {
|
||||
let comp = new_comp("wallpaper")
|
||||
let slot = comp.shell.slot_of("wallpaper")
|
||||
let slot = comp.shell.slot_of("session-settings")
|
||||
assert_true(comp.shell.slot_rect(slot).w > 0) // it is in the default panel
|
||||
assert_eq(comp.shell.slot_of("wallpaper"), "") // the standalone chooser is gone
|
||||
assert_eq(comp.shell.wallpaper_sel, 0)
|
||||
// A click opens the list; nothing changes yet.
|
||||
click_module(comp, "wallpaper", 1U)
|
||||
// A click opens the list; nothing changes yet. The wallpapers follow the three settings and a
|
||||
// "Wallpaper" heading, so the first is row 4.
|
||||
click_module(comp, "session-settings", 1U)
|
||||
let pr = comp.shell.slot_popup_rect(slot)
|
||||
assert_true(pr.h >= 6 * 2 + 5 * 30) // one row per wallpaper
|
||||
assert_true(pr.h >= 6 * 2 + (4 + 5) * 30) // one row per setting and wallpaper, and the heading
|
||||
assert_eq(comp.shell.wallpaper_sel, 0)
|
||||
// Third row: Starfield. The list stays open and the backdrop is drawn anew.
|
||||
let star = click_wallpaper_ops(comp, pr.x + 40, pr.y + 6 + 2 * 30 + 5, 5U)
|
||||
// The heading does nothing.
|
||||
click_at(comp, pr.x + 40, pr.y + 6 + 3 * 30 + 5, 3U)
|
||||
assert_eq(comp.shell.wallpaper_sel, 0)
|
||||
// Third wallpaper: Starfield. The list stays open and the backdrop is drawn anew.
|
||||
let star = click_wallpaper_ops(comp, pr.x + 40, pr.y + 6 + (4 + 2) * 30 + 5, 5U)
|
||||
assert_eq(comp.shell.wallpaper_sel, 2)
|
||||
assert_true(star > 0)
|
||||
assert_true(comp.shell.slot_popup_rect(slot).w > 0)
|
||||
// Last row: Solid, a single fill. Escape then closes the list.
|
||||
assert_eq(click_wallpaper_ops(comp, pr.x + 40, pr.y + 6 + 4 * 30 + 5, 10U), 1)
|
||||
assert_eq(click_wallpaper_ops(comp, pr.x + 40, pr.y + 6 + (4 + 4) * 30 + 5, 10U), 1)
|
||||
assert_eq(comp.shell.wallpaper_sel, 4)
|
||||
comp.shell.key_down("Escape")
|
||||
ignore(comp.compose_frame())
|
||||
@@ -1255,7 +1260,7 @@ test "the open windows are saved as the session and a restored app's window gets
|
||||
}
|
||||
|
||||
///|
|
||||
test "the session settings module flips the session settings from its popup" {
|
||||
test "the settings module flips the session settings from its popup" {
|
||||
let comp = new_comp("sessset")
|
||||
let slot = comp.shell.slot_of("session-settings")
|
||||
assert_true(comp.shell.slot_rect(slot).w > 0) // it is in the default panel
|
||||
@@ -1264,7 +1269,7 @@ test "the session settings module flips the session settings from its popup" {
|
||||
// A click opens the list of switches; nothing changes yet.
|
||||
click_module(comp, "session-settings", 1U)
|
||||
let pr = comp.shell.slot_popup_rect(slot)
|
||||
assert_true(pr.h >= 6 * 2 + 2 * 32) // one row per setting
|
||||
assert_true(pr.h >= 6 * 2 + 3 * 30) // one row per setting
|
||||
assert_true(comp.shell.restore_session)
|
||||
// First row: "Reopen windows at login" goes off, and on again with a second click.
|
||||
click_at(comp, pr.x + 40, pr.y + 6 + 5, 5U)
|
||||
@@ -1274,12 +1279,22 @@ test "the session settings module flips the session settings from its popup" {
|
||||
click_at(comp, pr.x + 40, pr.y + 6 + 5, 10U)
|
||||
assert_true(comp.shell.restore_session)
|
||||
// Second row: "Remember window positions"; then Down and Enter flip it back from the keyboard.
|
||||
click_at(comp, pr.x + 40, pr.y + 6 + 32 + 5, 15U)
|
||||
click_at(comp, pr.x + 40, pr.y + 6 + 30 + 5, 15U)
|
||||
assert_false(comp.shell.remember_windows)
|
||||
comp.shell.key_down("Enter")
|
||||
ignore(comp.compose_frame())
|
||||
assert_true(comp.shell.remember_windows)
|
||||
assert_true(comp.shell.restore_session)
|
||||
// Third row: Dark mode. Off switches the shell, panel and decorations to the light theme.
|
||||
assert_eq(comp.theme.name, "Moon Night")
|
||||
click_at(comp, pr.x + 40, pr.y + 6 + 2 * 30 + 5, 20U)
|
||||
assert_false(comp.shell.dark_mode)
|
||||
assert_eq(comp.theme.name, "Moon Day")
|
||||
assert_eq(comp.shell.tokens.name, "Moon Day")
|
||||
comp.shell.key_down("Enter") // the highlight stayed on Dark mode
|
||||
ignore(comp.compose_frame())
|
||||
assert_true(comp.shell.dark_mode)
|
||||
assert_eq(comp.theme.name, "Moon Night")
|
||||
comp.shell.key_down("Escape")
|
||||
ignore(comp.compose_frame())
|
||||
assert_eq(comp.shell.slot_popup_rect(slot).w, 0)
|
||||
@@ -1323,5 +1338,16 @@ test "session settings are saved to state.edn and restored, and take effect" {
|
||||
assert_false(text2.contains(":remember-windows"))
|
||||
assert_eq(b.shell.load_session().length(), 1)
|
||||
assert_eq(b.shell.saved_window("foot"), Some((10, 20, 300, 200)))
|
||||
// Dark mode off is saved as :theme :light and the next start comes up light.
|
||||
b.shell.set_session_setting(2, false)
|
||||
assert_true(read_state_edn().contains(":theme :light"))
|
||||
let c = new_comp("sess-c")
|
||||
c.shell.persist = true
|
||||
assert_eq(c.theme.name, "Moon Night")
|
||||
c.restore_state()
|
||||
assert_false(c.shell.dark_mode)
|
||||
assert_eq(c.theme.name, "Moon Day")
|
||||
c.shell.set_session_setting(2, true)
|
||||
assert_false(read_state_edn().contains(":theme"))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user