- 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
@@ -198,6 +198,8 @@ pub(all) struct DesktopShell {
|
||||
/// Desktop card position (once moved) and drag state.
|
||||
/// How many of the background ops are the static wallpaper (the rest is the desktop card).
|
||||
mut wallpaper_len : Int
|
||||
/// Which wallpaper is drawn (an index into `@libshell.wallpaper_names`); the wallpaper module sets it.
|
||||
mut wallpaper_sel : Int
|
||||
mut desk_set : Bool
|
||||
mut desk_x : Int
|
||||
mut desk_y : Int
|
||||
@@ -276,6 +278,7 @@ pub fn DesktopShell::new(display : String) -> DesktopShell {
|
||||
tokens: conv_theme(@scene.ThemeTokens::moon_night()),
|
||||
screen_w: 0,
|
||||
wallpaper_len: 0,
|
||||
wallpaper_sel: 0,
|
||||
desk_set: false,
|
||||
desk_x: 0,
|
||||
desk_y: 0,
|
||||
@@ -765,7 +768,7 @@ pub fn DesktopShell::render(
|
||||
@wasm.set_windows(self.win_list)
|
||||
}
|
||||
let bg : Array[@scene.DrawOp] = []
|
||||
translate(@libshell.render_background(@ui.size(w, h), tokens), 0, 0, bg)
|
||||
translate(@libshell.render_wallpaper(@ui.size(w, h), tokens, self.wallpaper_sel), 0, 0, bg)
|
||||
self.wallpaper_len = bg.length()
|
||||
let (dx, dy) = self.desk_pos()
|
||||
render_desktop_widget(dx, dy, tokens, now(), bg)
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
/// {:layout :tiling ; the Tile | Float switcher: :tiling, :monocle or :floating
|
||||
/// :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)
|
||||
/// :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)
|
||||
///
|
||||
/// Saving merges into what is already in the file, so keys this build doesn't know (a future
|
||||
/// widget's state, hand-written notes) survive. Everything is a no-op unless `persist` is on
|
||||
@@ -19,6 +20,8 @@ pub(all) struct SavedState {
|
||||
/// Top-left of the desktop card, when it was moved.
|
||||
desk : (Int, Int)?
|
||||
windows : Map[String, (Int, Int, Int, Int)]
|
||||
/// Index into `@libshell.wallpaper_names`.
|
||||
wallpaper : Int?
|
||||
}
|
||||
|
||||
///|
|
||||
@@ -30,7 +33,10 @@ fn state_path() -> String {
|
||||
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"]
|
||||
let owned_keys : Array[String] = ["layout", "recent", "desktop-card", "windows", "wallpaper"]
|
||||
|
||||
///| How state.edn names each wallpaper, in `@libshell.wallpaper_names` order.
|
||||
let wallpaper_keys : Array[String] = ["plasma-glow", "aurora", "starfield", "dusk", "solid"]
|
||||
|
||||
///|
|
||||
fn read_state_file() -> Array[(@edn.Value, @edn.Value)] {
|
||||
@@ -62,7 +68,7 @@ fn lookup_key(
|
||||
///| Read state.edn. Without `persist` nothing is read.
|
||||
pub fn DesktopShell::load_state(self : DesktopShell) -> SavedState {
|
||||
if !self.persist {
|
||||
return { layout: None, recent: None, desk: None, windows: {} }
|
||||
return { layout: None, recent: None, desk: None, windows: {}, wallpaper: None }
|
||||
}
|
||||
let entries = read_state_file()
|
||||
let layout = match lookup_key(entries, "layout") {
|
||||
@@ -135,7 +141,19 @@ pub fn DesktopShell::load_state(self : DesktopShell) -> SavedState {
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
{ layout, recent, desk, windows }
|
||||
let wallpaper = match lookup_key(entries, "wallpaper") {
|
||||
Some(Keyword(k)) => {
|
||||
let mut found : Int? = None
|
||||
for i = 0; i < wallpaper_keys.length(); i = i + 1 {
|
||||
if wallpaper_keys[i] == k {
|
||||
found = Some(i)
|
||||
}
|
||||
}
|
||||
found
|
||||
}
|
||||
_ => None
|
||||
}
|
||||
{ layout, recent, desk, windows, wallpaper }
|
||||
}
|
||||
|
||||
///| Take the saved recents (the layout is the compositor's to apply).
|
||||
@@ -143,6 +161,10 @@ pub fn DesktopShell::apply_state(self : DesktopShell, st : SavedState) -> Unit {
|
||||
for app, g in st.windows {
|
||||
self.win_geoms.set(app, g)
|
||||
}
|
||||
match st.wallpaper {
|
||||
Some(i) => self.wallpaper_sel = i
|
||||
None => ()
|
||||
}
|
||||
match st.desk {
|
||||
Some((x, y)) => {
|
||||
self.desk_set = true
|
||||
@@ -211,6 +233,9 @@ pub fn DesktopShell::save_state(self : DesktopShell) -> Unit {
|
||||
(@edn.Value::Keyword("y"), @edn.Value::Integer(y.to_string())),
|
||||
])))
|
||||
}
|
||||
if self.wallpaper_sel > 0 && self.wallpaper_sel < wallpaper_keys.length() {
|
||||
entries.insert(2, (@edn.Value::Keyword("wallpaper"), @edn.Value::Keyword(wallpaper_keys[self.wallpaper_sel])))
|
||||
}
|
||||
let body : String? = try Some(@edn.pretty(@edn.Value::Mapping(entries), layout={ width: 100, indent: 1 })) catch { _ => None }
|
||||
match body {
|
||||
Some(b) => {
|
||||
|
||||
@@ -11,7 +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", "logout",
|
||||
"launcher", "inspector", "layout", "tasks", "moon-disc", "clock-digital12", "wallpaper", "logout",
|
||||
]
|
||||
|
||||
///| The module whose popup is the wasm picker.
|
||||
@@ -382,6 +382,15 @@ fn DesktopShell::publish_host_data(self : DesktopShell) -> Unit {
|
||||
}
|
||||
@wasm.publish(Layouts, lt)
|
||||
@wasm.publish_state(self.layout_sel, self.inspect_on)
|
||||
if self.widgets.iter().any(w => w.has_cap("wallpaper")) {
|
||||
let pt = @wasm.Table::new()
|
||||
for n in @libshell.wallpaper_names {
|
||||
pt.str(n)
|
||||
pt.end_row()
|
||||
}
|
||||
@wasm.publish(Wallpapers, pt)
|
||||
@wasm.publish_wallpaper(self.wallpaper_sel)
|
||||
}
|
||||
let it = @wasm.Table::new()
|
||||
for w in self.widgets {
|
||||
it.str(w.slot)
|
||||
@@ -416,6 +425,16 @@ fn DesktopShell::publish_host_data(self : DesktopShell) -> Unit {
|
||||
}
|
||||
}
|
||||
|
||||
///| Show wallpaper `i` (ignored when out of range) and remember it in state.edn.
|
||||
pub fn DesktopShell::set_wallpaper(self : DesktopShell, i : Int) -> Unit {
|
||||
if i < 0 || i >= @libshell.wallpaper_names.length() || i == self.wallpaper_sel {
|
||||
return
|
||||
}
|
||||
self.wallpaper_sel = i
|
||||
@wasm.publish_wallpaper(i)
|
||||
self.save_state()
|
||||
}
|
||||
|
||||
///| Carry out what modules asked of the host during their last calls.
|
||||
fn DesktopShell::process_requests(self : DesktopShell) -> Unit {
|
||||
while true {
|
||||
@@ -436,6 +455,7 @@ fn DesktopShell::process_requests(self : DesktopShell) -> Unit {
|
||||
Some(FocusWindow(n)) => self.actions.push(FocusWindow(n.to_int64().to_uint64()))
|
||||
Some(SetLayout(m)) => self.actions.push(SetLayout(m))
|
||||
Some(Logout) => self.actions.push(Logout)
|
||||
Some(SetWallpaper(i)) => self.set_wallpaper(i)
|
||||
Some(SetInspector(on)) => self.set_inspecting(on)
|
||||
Some(LoadModule(path)) => {
|
||||
match self.load_path(path) {
|
||||
|
||||
Reference in new issue
Block a user