Desktop modules: a wasm module can fill the desktop, with Icon Desktop and Live Starfield
CI / test (push) Failing after 30s

A module that exports chandra:desktop/desktop-module (wit/desktop.wit) owns the desktop behind
the windows instead of a box in the panel: same sandbox, draw ops and capabilities, drawn at the
output's full size and re-rendered on resize. It gets pointer and scroll events only on the empty
desktop (windows, panel, popups and menus always win; a drag stays with the module until
release), keys only while the desktop has focus, and can draw over the wallpaper or replace it.
Its tick() asks for animation frames only while something moves; the main loop sleeps until the
next one (wake_timeout), and frames pause while a window covers the desktop, so an idle desktop
module costs nothing.

Settings > Desktop gets "On the desktop": Wallpaper only, Clock card (default) or any installed
desktop module, saved in state.edn as :desktop, loaded at login and reloaded by chandra-ctl
reload. Right-click the empty desktop for Module settings and System settings. Hidden settings
(empty label) are persisted by the shell, which is how Icon Desktop keeps icon positions.

Samples: Icon Desktop (click to launch, drag to arrange, keyboard navigation, count and size
settings) and Live Starfield (pointer steers, click or Space warps, wheel sets speed). Served by
all hosts: compositor/wasm (native + MoonBit wasmhost) and Rust host-wasm. Docs in
docs/desktop-modules.md; tests in compositor/host/desktop_test.mbt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hgf1SwPMHVfLUbJKsB
This commit is contained in:
Claude committed 2026-11-26 00:30:32 +00:00
1 parent 30f5e88639
commit 0f71779819
79 files changed
+4591 -113

No files matched your search

@@ -3,9 +3,9 @@
///
/// - Session: the session settings the shell offers (`session-settings.settings`: reopen windows
/// at login, remember window positions, dark mode), each with an on/off switch;
/// - Desktop: what is drawn on the desktop. Today that is the wallpaper (`wallpaper.wallpapers`,
/// the current one ticked); modules can't be placed on the desktop yet, so when they can they
/// get their own section here;
/// - Desktop: what fills the desktop (`wallpaper.desktops`: the wallpaper alone, the clock card,
/// or an installed desktop module, see docs/desktop-modules.md) and the wallpaper
/// (`wallpaper.wallpapers`), the current one of each ticked;
/// - Panel: the modules in the panel in panel order (left to right), each with move-up/down and
/// remove buttons; then the modules that can be added, grouped by kind with a short description
/// and an Add button (a module already in the panel is left out unless more than one makes
@@ -68,6 +68,8 @@ enum Row {
Heading(String)
Setting(Int, String)
Wallpaper(Int, String)
/// What fills the desktop: wallpaper only, the clock card, or a desktop module.
DesktopChoice(Int, String)
/// A group of modules in the Add list ("Clocks").
Category(String)
/// A loaded panel instance: slot, name, its place in the panel and how many there are.
@@ -190,6 +192,11 @@ fn rows() -> Array[Row] {
}
}
1 => {
rs.push(Heading("On the desktop"))
let desks = @wallpaper.desktops()
for i = 0; i < desks.length(); i = i + 1 {
rs.push(DesktopChoice(i, desks[i]))
}
rs.push(Heading("Wallpaper"))
let names = @wallpaper.wallpapers()
for i = 0; i < names.length(); i = i + 1 {
@@ -469,6 +476,7 @@ fn act(rs : Array[Row], i : Int, btn~ : Int = -1, x~ : Int = 0) -> Unit {
@settings.set_setting(idx, !@settings.is_on(idx))
}
Wallpaper(k, _) => @wallpaper.set_wallpaper(k.reinterpret_as_uint())
DesktopChoice(k, _) => @wallpaper.set_desktop(k.reinterpret_as_uint())
Loaded(slot, _, idx, n) =>
match btn {
0 => if idx > 0 { @modules.move_instance(slot, -1) }
@@ -581,6 +589,7 @@ pub fn popup() -> PopupSurface? {
}
ops.push(@ui.line(margin, rows_top - 3, w - margin, rows_top - 3, p.border, width=1))
let cur_wall = @wallpaper.current_wallpaper().reinterpret_as_int()
let cur_desk = if tab.val == 1 { @wallpaper.current_desktop().reinterpret_as_int() } else { -1 }
for i = 0; i < rs.length(); i = i + 1 {
let y = tops[i]
let rh = row_height(rs[i])
@@ -620,6 +629,13 @@ pub fn popup() -> PopupSurface? {
ops.push(@ui.circle(sx + switch_h / 2, mid, knob, p.foreground_muted))
}
}
DesktopChoice(k, name) => {
if k == cur_desk {
ops.push(@ui.line(margin + 8, mid, margin + 11, mid + 4, list_fg, width=2))
ops.push(@ui.line(margin + 11, mid + 4, margin + 18, mid - 4, list_fg, width=2))
}
ops.push(@ui.text(margin + 26, mid, name, fs - 1, list_fg, bold=k == cur_desk))
}
Wallpaper(k, name) => {
if k == cur_wall {
// A tick: two strokes.