CI / test (push) Failing after 16s
- New 'session-settings' capability (wit/capabilities.wit: settings, is-on, set-setting) and 'session-settings' panel module: a "Session" button whose popup lists the session settings, each with an on/off switch. Clicking a row flips it at once (the list stays open); Up/Down move the highlight, Enter or Space flips it, Escape or a click elsewhere closes. In the default panel, between Wallpaper and Log out. - Two settings to start with, kept in state.edn and written only when off (absent means on): "Reopen windows at login" (:restore-session, the key session restore already read) and "Remember window positions" (:remember-windows; when off, floating windows aren't placed where their app was left and new places aren't recorded, but the saved ones are kept). - Served by both hosts: wasmer stub (native; settings table 6, bit mask in host int 3, requests 10/11) and host-wasm (publish-session-settings, set-session-setting request). - Tests: native end-to-end (open, click both rows, keyboard, Escape), a state.edn round trip that checks both settings take effect, and a host-wasm module test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hgxf6exeYrDGcy4WW3
110 lines
3.7 KiB
Plaintext
110 lines
3.7 KiB
Plaintext
package chandra:host@0.1.0;
|
|
|
|
/// Panel modules (plasmoids) for a compositor that is itself a component. A component can't embed
|
|
/// a second wasm runtime, so the host runs the modules (wasmtime) and the compositor drives them
|
|
/// through this interface. It mirrors compositor/wasm: load, draw, events, plus the host data a
|
|
/// module may read and the requests it may make.
|
|
interface plasmoids {
|
|
use chandra:desktop/types@0.1.0.{draw-op, input-event, size};
|
|
use chandra:desktop/theme@0.1.0.{tokens};
|
|
|
|
/// A loaded module. `imports` is its capability grant: the host interfaces its binary imports
|
|
/// (besides theme), e.g. ["clock"] or ["windows", "system"].
|
|
record loaded {
|
|
handle: u32,
|
|
id: string,
|
|
name: string,
|
|
preferred: size,
|
|
min-width: u32,
|
|
stretch: bool,
|
|
imports: list<string>,
|
|
}
|
|
/// Load the plasmoid component at `path`. The error is a short reason.
|
|
load: func(path: string) -> result<loaded, string>;
|
|
unload: func(handle: u32);
|
|
|
|
/// The theme the modules see through `theme.get-tokens` (set before drawing so a swap shows at once).
|
|
set-tokens: func(t: tokens);
|
|
render: func(handle: u32, box: size) -> list<draw-op>;
|
|
|
|
record popup-surface {
|
|
box: size,
|
|
ops: list<draw-op>,
|
|
}
|
|
popup: func(handle: u32) -> option<popup-surface>;
|
|
/// Deliver an event to the module (`on-popup`: to its popup surface). True when it wants a redraw.
|
|
on-event: func(handle: u32, on-popup: bool, event: input-event) -> bool;
|
|
|
|
// ---- 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
|
|
/// i32 ('i') or a LE u32 byte length + UTF-8 ('s'). `which`: 0 apps (sssss: id name comment
|
|
/// category glyph), 1 windows (isii: id title focused minimized), 2 layouts (s), 3 modules
|
|
/// (sssi: id name path loaded), 4 instances (sss: slot module name), 5 wallpapers (s), 6 session settings (s).
|
|
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);
|
|
/// Which session settings are on: bit i for row i of the session settings table.
|
|
publish-session-settings: func(on: u32);
|
|
|
|
record system-snapshot {
|
|
cpu-permille: u32,
|
|
mem-used-kib: u64,
|
|
mem-total-kib: u64,
|
|
battery-percent: s32,
|
|
charging: bool,
|
|
uptime-secs: u64,
|
|
net-rx-bytes-per-sec: u64,
|
|
net-tx-bytes-per-sec: u64,
|
|
load-centi: u32,
|
|
}
|
|
publish-system: func(s: system-snapshot);
|
|
|
|
record window-entry {
|
|
id: u64,
|
|
title: string,
|
|
app-id: string,
|
|
focused: bool,
|
|
}
|
|
publish-windows: func(wins: list<window-entry>);
|
|
|
|
/// A module turning a session setting on or off.
|
|
record setting-change {
|
|
index: s32,
|
|
on: bool,
|
|
}
|
|
|
|
// ---- what modules asked of the host ----
|
|
|
|
variant request {
|
|
launch(string),
|
|
focus-window(s32),
|
|
set-layout(s32),
|
|
set-inspector(bool),
|
|
load-module(string),
|
|
unload-instance(string),
|
|
browse,
|
|
logout,
|
|
set-wallpaper(s32),
|
|
set-session-setting(setting-change),
|
|
}
|
|
/// The next pending request, oldest first.
|
|
next-request: func() -> option<request>;
|
|
/// A window a module asked to focus through `windows.focus` (64-bit id), since the last call.
|
|
take-focus-request: func() -> option<u64>;
|
|
|
|
/// Names of the `*.wasm` files directly in `dir`, sorted.
|
|
list-wasm-files: func(dir: string) -> list<string>;
|
|
|
|
/// A native file-chooser dialog (zenity on the host session) for "Add widget".
|
|
variant picker-state {
|
|
open,
|
|
cancelled,
|
|
chosen(string),
|
|
}
|
|
picker-start: func() -> bool;
|
|
picker-poll: func() -> picker-state;
|
|
}
|