Files
chandra/wit/worlds.wit
T
Claude 0f71779819
CI / test (push) Failing after 30s
Desktop modules: a wasm module can fill the desktop, with Icon Desktop and Live Starfield
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
2026-11-26 00:30:32 +00:00

168 lines
4.6 KiB
Plaintext

package chandra:desktop@0.1.0;
/// Minimum every widget gets: theme tokens. Everything else is opt-in.
world widget {
import theme;
export plasmoid;
}
world clock-widget {
include widget;
import clock;
export module-config;
}
/// The optional `module-config` export on its own. A module of any world may add it to get its own
/// settings in its right-click menu; hosts look it up separately (host-wasm binds it with this world).
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 {
include widget;
import app-catalog;
import app-launch;
import session;
import power;
}
/// The dock: pinned apps plus running ones, with their theme icons, a dot per open window, a click
/// that starts the app or brings its windows forward, and right-click settings (icon size,
/// magnification, running apps). The shell keeps the pinned list (hidden `pinned` setting) and
/// draws the per-app right-click menu (Pin, Move, Quit), sharing lib/dock's layout.
world dock-widget {
include widget;
import app-catalog;
import app-launch;
import windows;
import icons;
export module-config;
}
world panel {
import theme;
export panel-layout;
}
/// Reference shell: panel + desktop background in one component.
world shell {
import theme;
export desktop-surface;
export panel-layout;
}
/// Desktop Pulse: reads machine state and the window list, and can raise a window.
world pulse-widget {
include widget;
import system;
import windows;
}
/// Layout switcher.
world layout-widget {
include widget;
import layout-control;
}
/// Interface Explorer toggle.
world inspector-widget {
include widget;
import inspector;
}
/// Everything a panel module can be granted. The native host instantiates any module against this
/// one world (a module simply imports the subset it uses) and serves each import from the data the
/// compositor publishes (wit/host/plasmoids.wit).
world plasmoid-host {
import theme;
import clock;
import app-catalog;
import app-launch;
import windows;
import layout-control;
import inspector;
import modules;
import system;
import session;
import wallpaper;
import session-settings;
import icons;
import screenshot;
import power;
import battery;
import network;
import shortcuts;
import default-apps;
export plasmoid;
}
/// The settings module: session switches (restore, window places, dark mode), the wallpaper, the
/// panel's modules (load, unload, browse; the panel menu's "Modules..." opens that tab), and power
/// (idle timeouts, battery, suspend / restart / power off), keyboard shortcuts (rebind, reset) and
/// default apps (browser, email, files, terminal, editor, viewers and players).
world session-settings-widget {
include widget;
import session-settings;
import wallpaper;
import modules;
import power;
import system;
import shortcuts;
import default-apps;
}
/// Screenshot and screen recording launcher.
world screenshot-widget {
include widget;
import screenshot;
}
/// Battery charge, charging state and time left in the panel; its right-click settings choose what
/// shows.
world battery-widget {
include widget;
import battery;
export module-config;
}
/// Network status (Ethernet, Wi-Fi name and signal, offline) and a popup to pick a Wi-Fi network,
/// connect, disconnect, and switch Wi-Fi or airplane mode.
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;
}