Session settings panel module: switch session restore and window placement on or off
CI / test (push) Failing after 16s
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
This commit is contained in:
32 files changed
+1192
-44
No files matched your search
@@ -47,16 +47,17 @@ 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_WALLPAPERS, K_WALLPAPER_CUR, K_SET_WALLPAPER
|
||||
K_SYSTEM_READ, K_WIN_ALL, K_WIN_FOCUS_ID, K_LOGOUT, K_WALLPAPERS, K_WALLPAPER_CUR, K_SET_WALLPAPER,
|
||||
K_SESSION_SETTINGS, K_SESSION_IS_ON, K_SESSION_SET
|
||||
};
|
||||
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_WALLPAPERS, T_N };
|
||||
enum { T_APPS, T_WINDOWS, T_LAYOUTS, T_MODULES, T_INSTANCES, T_WALLPAPERS, T_SESSION_SETTINGS, 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, 2 current wallpaper */
|
||||
static int32_t host_ints[4]; /* 0 layout mode, 1 inspector on, 2 current wallpaper, 3 session settings on (bit i: row i) */
|
||||
|
||||
/* ---- 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;
|
||||
@@ -265,6 +266,7 @@ static wasm_trap_t *host_import(void *env, const wasm_val_vec_t *args, wasm_val_
|
||||
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_SESSION_SETTINGS: build_list(in, T_SESSION_SETTINGS, "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:
|
||||
@@ -273,6 +275,10 @@ static wasm_trap_t *host_import(void *env, const wasm_val_vec_t *args, wasm_val_
|
||||
case K_WALLPAPER_CUR:
|
||||
if (results->size >= 1) results->data[0] = (wasm_val_t)WASM_I32_VAL(host_ints[2]);
|
||||
break;
|
||||
case K_SESSION_IS_ON:
|
||||
if (results->size >= 1)
|
||||
results->data[0] = (wasm_val_t)WASM_I32_VAL(a0 >= 0 && a0 < 32 ? (int32_t)(((uint32_t)host_ints[3] >> a0) & 1u) : 0);
|
||||
break;
|
||||
case K_INSPECT_IS_ON:
|
||||
if (results->size >= 1) results->data[0] = (wasm_val_t)WASM_I32_VAL(host_ints[1]);
|
||||
break;
|
||||
@@ -280,6 +286,7 @@ static wasm_trap_t *host_import(void *env, const wasm_val_vec_t *args, wasm_val_
|
||||
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_SESSION_SET: push_req(a1 ? 11 : 10, a0, NULL); break; /* 10 off, 11 on */
|
||||
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; }
|
||||
@@ -411,6 +418,9 @@ static int classify_import(const wasm_name_t *m, const wasm_name_t *f) {
|
||||
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, "session-settings") && !strcmp(fn, "settings")) return K_SESSION_SETTINGS;
|
||||
if (!strcmp(iface, "session-settings") && !strcmp(fn, "is-on")) return K_SESSION_IS_ON;
|
||||
if (!strcmp(iface, "session-settings") && !strcmp(fn, "set-setting")) return K_SESSION_SET;
|
||||
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