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

+7
View File
@@ -140,6 +140,13 @@ interface wallpaper {
current-wallpaper: func() -> u32;
/// Show wallpaper `index` (out-of-range indices are ignored). The choice is remembered.
set-wallpaper: func(index: u32);
/// What fills the desktop, as display names indexed by choice: 0 "Wallpaper only", 1 "Clock
/// card" (the built-in card), then every installed desktop module (docs/desktop-modules.md).
desktops: func() -> list<string>;
current-desktop: func() -> u32;
/// Put desktop `index` on the desktop (out-of-range indices are ignored). The choice is
/// remembered (state.edn `:desktop`).
set-desktop: func(index: u32);
}
/// Session settings: how the login session starts, what it remembers and how it looks (dark or
+48
View File
@@ -0,0 +1,48 @@
package chandra:desktop@0.1.0;
/// Optional export that turns a module into a desktop module: instead of a box in the panel it
/// owns the desktop itself, the whole output behind the windows (see docs/desktop-modules.md).
///
/// A desktop module is still a plasmoid (it exports `plasmoid` as well, and may export
/// `module-config` and import any capability a panel module can), so the same sandbox, draw ops
/// and capability grants apply. What changes is how the shell drives it:
///
/// - `plasmoid.render` is called with the output's full size (and again with the new size when
/// the output is resized), in desktop coordinates: (0, 0) is the output's top-left corner.
/// The panel and windows are drawn on top; the module draws the whole area.
/// - `plasmoid.on-event` gets the pointer (move, press, release, leave) only where no window,
/// panel, popup or menu covers the desktop, and keys only while the desktop has keyboard focus
/// (after a click on it, until a window is focused: it then gets `focus-lost`). A right-click
/// on the empty desktop always opens the shell's desktop menu (module settings, system
/// settings), never reaches the module.
/// - `plasmoid.popup` and `plasmoid.info`'s size fields are not used.
/// - Hidden settings (a `module-config` item with an empty label) are saved by the shell in
/// state.edn whenever their value changes after an event, and handed back at the next load:
/// that is how a desktop module keeps state such as icon positions.
interface desktop-module {
use types.{point};
/// What happens to the wallpaper under the module.
enum wallpaper-mode {
/// The wallpaper is drawn first and the module draws over it (leaving parts transparent).
over-wallpaper,
/// The module draws the whole background itself; the wallpaper is not drawn.
replace-wallpaper,
}
/// Read once, right after loading.
backdrop: func() -> wallpaper-mode;
/// Wheel or touchpad scroll over the empty desktop at `at`: `dx` / `dy` in pixels (positive:
/// right / down; one wheel notch is about 10). True when the module wants a redraw.
on-scroll: func(at: point, dx: s32, dy: s32) -> bool;
/// The animation clock. `now-ms` counts milliseconds from when the module was loaded. It is
/// called once after loading, after every event the module handled, and again when the delay it
/// last returned has passed. The module is redrawn after each timed call (an animation frame)
/// and after events that returned true; a call that follows an event only reschedules the
/// clock and does not redraw by itself. Return how many ms until the
/// next frame (16 for about 60 frames a second, 33 for 30), or 0 to sleep until the next event:
/// an idle desktop module costs nothing, so return 0 whenever nothing moves. Frames are paused
/// (no calls) while a window covers the whole desktop.
tick: func(now-ms: u32) -> u32;
}
+16 -1
View File
@@ -48,6 +48,16 @@ interface plasmoids {
/// Set one of them. True when the module wants a redraw (false without module-config).
set-config: func(handle: u32, key: string, value: string) -> bool;
/// Desktop modules (chandra:desktop/desktop-module, wit/desktop.wit): the module's backdrop (0
/// over the wallpaper, 1 replacing it), or -1 when it doesn't export desktop-module (a panel
/// module).
desktop-backdrop: func(handle: u32) -> s32;
/// Scroll over the desktop at (x, y), `dx` / `dy` pixels. True when it wants a redraw.
desktop-scroll: func(handle: u32, x: s32, y: s32, dx: s32, dy: s32) -> bool;
/// The module's animation clock (`now-ms` since it was loaded): ms until it wants the next
/// frame, 0 for none.
desktop-tick: func(handle: u32, now-ms: u32) -> u32;
// ---- host data modules read through their capabilities ----
/// Row tables, as built by compositor/wasm: a LE u32 row count, then per row each field as a LE
@@ -58,12 +68,15 @@ interface plasmoids {
/// 8 network status (one row, iissiiii: state signal name message wifi-enabled airplane
/// can-manage has-wifi), 9 Wi-Fi networks (siiii: ssid signal secured active saved), 10 keyboard
/// shortcuts (ssssi: name binding default-binding conflict capturing), 11 default-app
/// categories (sss: name current missing), 12 default-app choices (issii: category id name icon current).
/// categories (sss: name current missing), 12 default-app choices (issii: category id name icon current),
/// 20 desktops (s: name) served by `wallpaper.desktops`.
publish-table: func(which: u32, rows: list<u8>);
/// Layout mode (0 tiling, 1 monocle, 2 floating) and whether the Interface Explorer is on.
publish-state: func(layout-mode: s32, inspector-on: bool);
/// The wallpaper on the desktop now (an index into the wallpapers table).
publish-wallpaper: func(current: s32);
/// What is on the desktop now (an index into the desktops table).
publish-desktop: func(current: s32);
/// Which session settings are on: bit i for row i of the session settings table.
publish-session-settings: func(on: u32);
/// The power timeouts, in minutes (0: never).
@@ -146,6 +159,8 @@ interface plasmoids {
/// The default-apps capability: category * 1000 + app (set that category's default to its
/// app-th app), or -1 to scan the apps and defaults again.
default-app(s32),
/// The wallpaper capability's `set-desktop`: an index into the desktops table.
set-desktop(s32),
}
/// The next pending request, oldest first.
next-request: func() -> option<request>;
+32
View File
@@ -18,6 +18,12 @@ world configurable {
export module-config;
}
/// The optional `desktop-module` export on its own (wit/desktop.wit): what makes a module a
/// desktop module. Hosts look it up by name like `module-config` (host-wasm binds this world).
world desktop-export {
export desktop-module;
}
/// The application launcher. The launcher's popup
/// also ends in a session row: Reload, Log out, Suspend, Restart, Power off.
world launcher-widget {
@@ -133,3 +139,29 @@ world network-widget {
include widget;
import network;
}
/// A desktop module (wit/desktop.wit): a plasmoid drawn full screen behind the windows. The
/// minimum: theme tokens in, draw ops and input, the animation clock.
world desktop-widget {
include widget;
export desktop-module;
}
/// Sample desktop module: app icons on the desktop. Click one to start the app, drag it to
/// arrange the grid (positions are kept as a hidden setting); arrow keys, Enter and typing pick
/// one. Its settings choose how many apps and how big.
world icon-desktop-widget {
include desktop-widget;
import app-catalog;
import app-launch;
import icons;
export module-config;
}
/// Sample desktop module: an animated starfield replacing the wallpaper. The pointer steers it,
/// the wheel changes speed, a click sends a warp pulse; it animates at 30 frames a second and
/// sleeps when its settings say Still.
world starfield-widget {
include desktop-widget;
export module-config;
}