- New 'wallpaper' capability (wit/capabilities.wit: wallpapers, current-wallpaper, set-wallpaper) and 'wallpaper' panel module: a button whose popup lists the wallpapers with the current one ticked. Clicking a row switches the desktop at once (the list stays open to compare); Enter picks the highlighted row, Escape or a click elsewhere closes. In the default panel, before Log out. - lib/shell: render_wallpaper(screen, tokens, index) with Plasma glow (the old background), Aurora, Starfield, Dusk and Solid, all draw ops; the themed ones follow a theme swap. - The shell draws the chosen one (the renderer's wallpaper cache redraws it on change) and saves it in state.edn as :wallpaper (:aurora, ...); unknown names fall back to the default. - Served by both hosts: wasmer stub (native) and host-wasm (publish-wallpaper, wallpapers table 5, set-wallpaper request). - Tests: lib/shell wallpaper test, host-wasm module test, native end-to-end test (open, pick, Escape) and a state.edn round trip. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hhM8CTYpe2XVYTFQGn
This commit is contained in:
37 files changed
+1311
-78
No files matched your search
@@ -231,6 +231,7 @@ pub(all) enum HostTable {
|
||||
Layouts
|
||||
Modules
|
||||
Instances
|
||||
Wallpapers
|
||||
}
|
||||
|
||||
///|
|
||||
@@ -250,6 +251,7 @@ pub fn publish(which : HostTable, t : Table) -> Unit {
|
||||
Layouts => 2U
|
||||
Modules => 3U
|
||||
Instances => 4U
|
||||
Wallpapers => 5U
|
||||
}
|
||||
@hostpl.publish_table(id, out)
|
||||
}
|
||||
@@ -259,6 +261,11 @@ pub fn publish_state(layout_mode : Int, inspector_on : Bool) -> Unit {
|
||||
@hostpl.publish_state(layout_mode, inspector_on)
|
||||
}
|
||||
|
||||
///|
|
||||
pub fn publish_wallpaper(current : Int) -> Unit {
|
||||
@hostpl.publish_wallpaper(current)
|
||||
}
|
||||
|
||||
///| Something a module asked the host to do during a call.
|
||||
pub(all) enum HostRequest {
|
||||
Launch(String)
|
||||
@@ -269,6 +276,7 @@ pub(all) enum HostRequest {
|
||||
UnloadInstance(String)
|
||||
Browse
|
||||
Logout
|
||||
SetWallpaper(Int)
|
||||
} derive(Eq, Debug)
|
||||
|
||||
///|
|
||||
@@ -283,6 +291,7 @@ pub fn next_request() -> HostRequest? {
|
||||
Some(UnloadInstance(s)) => Some(UnloadInstance(s))
|
||||
Some(Browse) => Some(Browse)
|
||||
Some(Logout) => Some(Logout)
|
||||
Some(SetWallpaper(i)) => Some(SetWallpaper(i))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -607,6 +607,7 @@ pub(all) enum HostTable {
|
||||
Layouts
|
||||
Modules
|
||||
Instances
|
||||
Wallpapers
|
||||
}
|
||||
|
||||
///| Publish `t` as the data behind `which` for every module's next call.
|
||||
@@ -617,6 +618,7 @@ pub fn publish(which : HostTable, t : Table) -> Unit {
|
||||
Layouts => 2
|
||||
Modules => 3
|
||||
Instances => 4
|
||||
Wallpapers => 5
|
||||
}
|
||||
let out : Array[Byte] = []
|
||||
for k = 0; k < 4; k = k + 1 {
|
||||
@@ -634,6 +636,11 @@ pub fn publish_state(layout_mode : Int, inspector_on : Bool) -> Unit {
|
||||
c_host_set_int(1, if inspector_on { 1 } else { 0 })
|
||||
}
|
||||
|
||||
///| Publish which wallpaper (an index into the Wallpapers table) is on the desktop.
|
||||
pub fn publish_wallpaper(current : Int) -> Unit {
|
||||
c_host_set_int(2, current)
|
||||
}
|
||||
|
||||
///| Something a module asked the host to do during a call.
|
||||
pub(all) enum HostRequest {
|
||||
Launch(String)
|
||||
@@ -644,6 +651,7 @@ pub(all) enum HostRequest {
|
||||
UnloadInstance(String)
|
||||
Browse
|
||||
Logout
|
||||
SetWallpaper(Int)
|
||||
} derive(Eq, Debug)
|
||||
|
||||
///|
|
||||
@@ -664,6 +672,7 @@ pub fn next_request() -> HostRequest? {
|
||||
6 => Some(UnloadInstance(req_str()))
|
||||
7 => Some(Browse)
|
||||
8 => Some(Logout)
|
||||
9 => Some(SetWallpaper(c_host_req_int()))
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,16 +47,16 @@ static Inst insts[MAX_INST];
|
||||
enum {
|
||||
K_OTHER, K_TOKENS, K_CLOCK, K_APPS, K_LAUNCH, K_WINDOWS, K_FOCUS, K_LAYOUTS, K_LAYOUT_CUR, K_SET_LAYOUT,
|
||||
K_INSPECT_IS_ON, K_INSPECT_SET, K_MOD_AVAILABLE, K_MOD_LOADED, K_MOD_LOAD, K_MOD_UNLOAD, K_MOD_BROWSE,
|
||||
K_SYSTEM_READ, K_WIN_ALL, K_WIN_FOCUS_ID, K_LOGOUT
|
||||
K_SYSTEM_READ, K_WIN_ALL, K_WIN_FOCUS_ID, K_LOGOUT, K_WALLPAPERS, K_WALLPAPER_CUR, K_SET_WALLPAPER
|
||||
};
|
||||
typedef struct Env { Inst *inst; int kind; } Env;
|
||||
|
||||
/* ---- host data the shell publishes before calling a guest ----
|
||||
* A table is [u32 rows] then rows of fields, each field a LE i32 ('i') or a u32 byte length + UTF-8 ('s'). */
|
||||
enum { T_APPS, T_WINDOWS, T_LAYOUTS, T_MODULES, T_INSTANCES, T_N };
|
||||
enum { T_APPS, T_WINDOWS, T_LAYOUTS, T_MODULES, T_INSTANCES, T_WALLPAPERS, T_N };
|
||||
typedef struct { uint8_t *data; size_t len; } Blob;
|
||||
static Blob tables[T_N];
|
||||
static int32_t host_ints[4]; /* 0 layout mode, 1 inspector on */
|
||||
static int32_t host_ints[4]; /* 0 layout mode, 1 inspector on, 2 current wallpaper */
|
||||
|
||||
/* ---- requests a guest made of the host (launch, focus, ...) ; drained by the shell after each call ---- */
|
||||
typedef struct { int kind; int32_t n; char *s; } Req;
|
||||
@@ -264,17 +264,22 @@ static wasm_trap_t *host_import(void *env, const wasm_val_vec_t *args, wasm_val_
|
||||
case K_APPS: build_list(in, T_APPS, "sssss", a0); break; /* id name comment category glyph */
|
||||
case K_WINDOWS: build_list(in, T_WINDOWS, "isii", a0); break;
|
||||
case K_LAYOUTS: build_list(in, T_LAYOUTS, "s", a0); break;
|
||||
case K_WALLPAPERS: build_list(in, T_WALLPAPERS, "s", a0); break;
|
||||
case K_MOD_AVAILABLE: build_list(in, T_MODULES, "sssi", a0); break;
|
||||
case K_MOD_LOADED: build_list(in, T_INSTANCES, "sss", a0); break;
|
||||
case K_LAYOUT_CUR:
|
||||
if (results->size >= 1) results->data[0] = (wasm_val_t)WASM_I32_VAL(host_ints[0]);
|
||||
break;
|
||||
case K_WALLPAPER_CUR:
|
||||
if (results->size >= 1) results->data[0] = (wasm_val_t)WASM_I32_VAL(host_ints[2]);
|
||||
break;
|
||||
case K_INSPECT_IS_ON:
|
||||
if (results->size >= 1) results->data[0] = (wasm_val_t)WASM_I32_VAL(host_ints[1]);
|
||||
break;
|
||||
case K_SET_LAYOUT: push_req(3, a0, NULL); break;
|
||||
case K_FOCUS: push_req(2, a0, NULL); break;
|
||||
case K_LOGOUT: push_req(8, 0, NULL); break;
|
||||
case K_SET_WALLPAPER: push_req(9, a0, NULL); break;
|
||||
case K_INSPECT_SET: push_req(4, a0, NULL); break;
|
||||
case K_MOD_BROWSE: push_req(7, 0, NULL); break;
|
||||
case K_MOD_LOAD: { char *s = guest_str(in, a0, a1); push_req(5, 0, s); free(s); break; }
|
||||
@@ -403,6 +408,9 @@ static int classify_import(const wasm_name_t *m, const wasm_name_t *f) {
|
||||
if (!strcmp(iface, "windows") && !strcmp(fn, "focus")) return K_WIN_FOCUS_ID;
|
||||
if (!strcmp(iface, "system") && !strcmp(fn, "read")) return K_SYSTEM_READ;
|
||||
if (!strcmp(iface, "session") && !strcmp(fn, "logout")) return K_LOGOUT;
|
||||
if (!strcmp(iface, "wallpaper") && !strcmp(fn, "wallpapers")) return K_WALLPAPERS;
|
||||
if (!strcmp(iface, "wallpaper") && !strcmp(fn, "current-wallpaper")) return K_WALLPAPER_CUR;
|
||||
if (!strcmp(iface, "wallpaper") && !strcmp(fn, "set-wallpaper")) return K_SET_WALLPAPER;
|
||||
if (!strcmp(iface, "layout-control") && !strcmp(fn, "layout-modes")) return K_LAYOUTS;
|
||||
if (!strcmp(iface, "layout-control") && !strcmp(fn, "current-layout")) return K_LAYOUT_CUR;
|
||||
if (!strcmp(iface, "layout-control") && !strcmp(fn, "set-layout")) return K_SET_LAYOUT;
|
||||
|
||||
Reference in new issue
Block a user