- New 'wallpaper' capability (wit/capabilities.wit: wallpapers, current-wallpaper, set-wallpaper) and 'wallpaper' panel module: a button whose popup lists the wallpapers with the current one ticked. Clicking a row switches the desktop at once (the list stays open to compare); Enter picks the highlighted row, Escape or a click elsewhere closes. In the default panel, before Log out. - lib/shell: render_wallpaper(screen, tokens, index) with Plasma glow (the old background), Aurora, Starfield, Dusk and Solid, all draw ops; the themed ones follow a theme swap. - The shell draws the chosen one (the renderer's wallpaper cache redraws it on change) and saves it in state.edn as :wallpaper (:aurora, ...); unknown names fall back to the default. - Served by both hosts: wasmer stub (native) and host-wasm (publish-wallpaper, wallpapers table 5, set-wallpaper request). - Tests: lib/shell wallpaper test, host-wasm module test, native end-to-end test (open, pick, Escape) and a state.edn round trip. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hhM8CTYpe2XVYTFQGn
This commit is contained in:
37 files changed
+1311
-78
No files matched your search
@@ -1121,3 +1121,66 @@ test "super+d minimizes every window to show the desktop, and again brings them
|
||||
key(32U, false, 21U)
|
||||
assert_false(comp.wm.windows.get(2UL).unwrap().minimized)
|
||||
}
|
||||
|
||||
///| Click (x, y) without drawing, then return the next scene's wallpaper op count (0: no new scene).
|
||||
fn click_wallpaper_ops(comp : @host.MoonPlasmaCompositor, x : Int, y : Int, t : UInt) -> Int {
|
||||
comp.handle_input(@nested.InputEvent::PointerMove(x.to_double(), y.to_double()), t)
|
||||
comp.handle_input(@nested.InputEvent::PointerButton(272U, true), t + 1U)
|
||||
comp.handle_input(@nested.InputEvent::PointerButton(272U, false), t + 2U)
|
||||
match comp.compose_scene() {
|
||||
Some(sg) => sg.wallpaper_ops.length()
|
||||
None => 0
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
test "the wallpaper module lists the wallpapers and switches the desktop to the one clicked" {
|
||||
let comp = new_comp("wallpaper")
|
||||
let slot = comp.shell.slot_of("wallpaper")
|
||||
assert_true(comp.shell.slot_rect(slot).w > 0) // it is in the default panel
|
||||
assert_eq(comp.shell.wallpaper_sel, 0)
|
||||
// A click opens the list; nothing changes yet.
|
||||
click_module(comp, "wallpaper", 1U)
|
||||
let pr = comp.shell.slot_popup_rect(slot)
|
||||
assert_true(pr.h >= 6 * 2 + 5 * 30) // one row per wallpaper
|
||||
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)
|
||||
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(comp.shell.wallpaper_sel, 4)
|
||||
comp.shell.key_down("Escape")
|
||||
ignore(comp.compose_frame())
|
||||
assert_eq(comp.shell.slot_popup_rect(slot).w, 0)
|
||||
// Out-of-range choices are ignored.
|
||||
comp.shell.set_wallpaper(99)
|
||||
assert_eq(comp.shell.wallpaper_sel, 4)
|
||||
}
|
||||
|
||||
///|
|
||||
test "the chosen wallpaper is saved to state.edn and restored" {
|
||||
if @sys.getenv("MOON_PLASMA_TEST_CONFIG") == "1" {
|
||||
write_state_edn("{:note \"keep\"}\n")
|
||||
let a = new_comp("wall-a")
|
||||
a.shell.persist = true
|
||||
a.restore_state()
|
||||
assert_eq(a.shell.wallpaper_sel, 0) // nothing saved: the default
|
||||
a.shell.set_wallpaper(1)
|
||||
let text = read_state_edn()
|
||||
assert_true(text.contains(":wallpaper :aurora"))
|
||||
assert_true(text.contains(":note \"keep\""))
|
||||
let b = new_comp("wall-b")
|
||||
b.shell.persist = true
|
||||
b.restore_state()
|
||||
assert_eq(b.shell.wallpaper_sel, 1)
|
||||
// An unknown name falls back to the default.
|
||||
write_state_edn("{:wallpaper :lava-lamp}\n")
|
||||
let c = new_comp("wall-c")
|
||||
c.shell.persist = true
|
||||
c.restore_state()
|
||||
assert_eq(c.shell.wallpaper_sel, 0)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user