Desktop modules: a wasm module can fill the desktop, with Icon Desktop and Live Starfield
CI / test (push) Failing after 30s
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:
79 files changed
+4591
-113
No files matched your search
@@ -246,6 +246,26 @@ pub fn Plasmoid::set_config(self : Plasmoid, key : String, value : String) -> Bo
|
||||
@hostpl.set_config(self.handle.reinterpret_as_uint(), key, value)
|
||||
}
|
||||
|
||||
///| A desktop module's backdrop: 0 over the wallpaper, 1 replacing it, -1 for a panel module.
|
||||
pub fn Plasmoid::desktop_backdrop(self : Plasmoid) -> Int {
|
||||
@hostpl.desktop_backdrop(self.handle.reinterpret_as_uint())
|
||||
}
|
||||
|
||||
///| Scroll over a desktop module at (x, y) by (dx, dy) pixels. True when it wants a redraw.
|
||||
pub fn Plasmoid::desktop_scroll(self : Plasmoid, x : Int, y : Int, dx : Int, dy : Int) -> Bool {
|
||||
@hostpl.desktop_scroll(self.handle.reinterpret_as_uint(), x, y, dx, dy)
|
||||
}
|
||||
|
||||
///| A desktop module's animation clock: ms until it wants the next frame, 0 for none.
|
||||
pub fn Plasmoid::desktop_tick(self : Plasmoid, now_ms : Int) -> Int {
|
||||
let r = @hostpl.desktop_tick(self.handle.reinterpret_as_uint(), now_ms.reinterpret_as_uint()).reinterpret_as_int()
|
||||
if r < 0 {
|
||||
0
|
||||
} else {
|
||||
r
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
pub fn Plasmoid::imports(self : Plasmoid) -> Array[String] {
|
||||
self.imports
|
||||
@@ -309,6 +329,8 @@ pub(all) enum HostTable {
|
||||
AppCategories
|
||||
/// Default-app choices (issii: category id name icon current).
|
||||
AppChoices
|
||||
/// What can fill the desktop (s: name), served by `wallpaper.desktops`.
|
||||
Desktops
|
||||
}
|
||||
|
||||
///|
|
||||
@@ -336,6 +358,7 @@ pub fn publish(which : HostTable, t : Table) -> Unit {
|
||||
Shortcuts => 10U
|
||||
AppCategories => 11U
|
||||
AppChoices => 12U
|
||||
Desktops => 20U
|
||||
}
|
||||
// Most tables are republished every frame unchanged: skip the copy into the host then.
|
||||
let slot = id.reinterpret_as_int()
|
||||
@@ -363,6 +386,11 @@ pub fn publish_wallpaper(current : Int) -> Unit {
|
||||
@hostpl.publish_wallpaper(current)
|
||||
}
|
||||
|
||||
///| What fills the desktop now (an index into the Desktops table).
|
||||
pub fn publish_desktop(current : Int) -> Unit {
|
||||
@hostpl.publish_desktop(current)
|
||||
}
|
||||
|
||||
///| Which session settings are on: bit i for row i of the SessionSettings table.
|
||||
pub fn publish_session_settings(on : Int) -> Unit {
|
||||
@hostpl.publish_session_settings(on.reinterpret_as_uint())
|
||||
@@ -416,6 +444,8 @@ pub(all) enum HostRequest {
|
||||
DefaultApp(Int)
|
||||
/// The session capability's `reload`: reload every loaded panel module from disk.
|
||||
ReloadSession
|
||||
/// The wallpaper capability's `set-desktop`: an index into the Desktops table.
|
||||
SetDesktop(Int)
|
||||
} derive(Eq, Debug)
|
||||
|
||||
///|
|
||||
@@ -441,6 +471,7 @@ pub fn next_request() -> HostRequest? {
|
||||
Some(Shortcut(code)) => Some(Shortcut(code))
|
||||
Some(DefaultApp(code)) => Some(DefaultApp(code))
|
||||
Some(ReloadSession) => Some(ReloadSession)
|
||||
Some(SetDesktop(i)) => Some(SetDesktop(i))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user