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
@@ -27,6 +27,9 @@ fn wasmImportPublishState(p0 : Int, p1 : Int) = "chandra:host/plasmoids@0.1.0"
|
||||
///|
|
||||
fn wasmImportPublishWallpaper(p0 : Int) = "chandra:host/plasmoids@0.1.0" "publish-wallpaper"
|
||||
|
||||
///|
|
||||
fn wasmImportPublishSessionSettings(p0 : Int) = "chandra:host/plasmoids@0.1.0" "publish-session-settings"
|
||||
|
||||
///|
|
||||
fn wasmImportPublishSystem(p0 : Int, p1 : Int64, p2 : Int64, p3 : Int, p4 : Int, p5 : Int64, p6 : Int64, p7 : Int64, p8 : Int) = "chandra:host/plasmoids@0.1.0" "publish-system"
|
||||
|
||||
@@ -48,35 +51,14 @@ fn wasmImportPickerStart() -> Int = "chandra:host/plasmoids@0.1.0" "picker-start
|
||||
///|
|
||||
fn wasmImportPickerPoll(p0 : Int) = "chandra:host/plasmoids@0.1.0" "picker-poll"
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
|
||||
#|(func (param i32) (result i32) (local i32)
|
||||
#| local.get 0 i32.const 4 i32.add call $moonbit.gc.malloc
|
||||
#| local.tee 1 i32.const 0 call $moonbit.init_array8
|
||||
#| local.get 1)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_free(position : Int) =
|
||||
#|(func (param i32) local.get 0 call $moonbit.decref)
|
||||
|
||||
///|
|
||||
#owned(str)
|
||||
extern "wasm" fn mbt_ffi_str2ptr(str : String) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_store8(offset : Int, value : Int) =
|
||||
#|(func (param i32) (param i32) local.get 0 local.get 1 i32.store8)
|
||||
|
||||
///|
|
||||
#owned(bytes)
|
||||
extern "wasm" fn mbt_ffi_bytes2ptr(bytes : FixedArray[Byte]) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load64(offset : Int) -> Int64 =
|
||||
#|(func (param i32) (result i64) local.get 0 i64.load)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load8_u(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load8_u)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_store32(offset : Int, value : Int) =
|
||||
#|(func (param i32) (param i32) local.get 0 local.get 1 i32.store)
|
||||
@@ -86,8 +68,33 @@ extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load8_u(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load8_u)
|
||||
#owned(str)
|
||||
extern "wasm" fn mbt_ffi_str2ptr(str : String) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
|
||||
#|(func (param i32) (result i32) (local i32)
|
||||
#| local.get 0 i32.const 4 i32.add call $moonbit.gc.malloc
|
||||
#| local.tee 1 i32.const 0 call $moonbit.init_array8
|
||||
#| local.get 1)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_store64(offset : Int, value : Int64) =
|
||||
#|(func (param i32) (param i64) local.get 0 local.get 1 i64.store)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_store8(offset : Int, value : Int) =
|
||||
#|(func (param i32) (param i32) local.get 0 local.get 1 i32.store8)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_free(position : Int) =
|
||||
#|(func (param i32) local.get 0 call $moonbit.decref)
|
||||
|
||||
///|
|
||||
#owned(bytes)
|
||||
extern "wasm" fn mbt_ffi_bytes2ptr(bytes : FixedArray[Byte]) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String =
|
||||
@@ -96,7 +103,3 @@ extern "wasm" fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String =
|
||||
#| local.get 1 call $moonbit.init_array16
|
||||
#| local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_store64(offset : Int, value : Int64) =
|
||||
#|(func (param i32) (param i64) local.get 0 local.get 1 i64.store)
|
||||
|
||||
@@ -45,6 +45,11 @@ fn wasmImportPublishWallpaper(p0 : Int) -> Unit {
|
||||
abort("wasm-only host import")
|
||||
}
|
||||
|
||||
///|
|
||||
fn wasmImportPublishSessionSettings(p0 : Int) -> Unit {
|
||||
abort("wasm-only host import")
|
||||
}
|
||||
|
||||
///|
|
||||
fn wasmImportPublishSystem(p0 : Int, p1 : Int64, p2 : Int64, p3 : Int, p4 : Int, p5 : Int64, p6 : Int64, p7 : Int64, p8 : Int) -> Unit {
|
||||
abort("wasm-only host import")
|
||||
|
||||
@@ -21,6 +21,8 @@ pub fn picker_start() -> Bool
|
||||
|
||||
pub fn popup(UInt32) -> PopupSurface?
|
||||
|
||||
pub fn publish_session_settings(UInt32) -> Unit
|
||||
|
||||
pub fn publish_state(Int32, Bool) -> Unit
|
||||
|
||||
pub fn publish_system(SystemSnapshot) -> Unit
|
||||
@@ -73,6 +75,12 @@ pub(all) enum Request {
|
||||
Browse
|
||||
Logout
|
||||
SetWallpaper(Int32)
|
||||
SetSessionSetting(SettingChange)
|
||||
}
|
||||
|
||||
pub(all) struct SettingChange {
|
||||
index : Int32
|
||||
on : Bool
|
||||
}
|
||||
|
||||
pub(all) struct SystemSnapshot {
|
||||
|
||||
@@ -18,6 +18,11 @@ pub(all) struct WindowEntry {
|
||||
id : UInt64; title : String; app_id : String; focused : Bool
|
||||
}
|
||||
///|
|
||||
/// A module turning a session setting on or off.
|
||||
pub(all) struct SettingChange {
|
||||
index : Int; on : Bool
|
||||
}
|
||||
///|
|
||||
/// ---- what modules asked of the host ----
|
||||
pub(all) enum Request {
|
||||
Launch(String)
|
||||
@@ -29,6 +34,7 @@ pub(all) enum Request {
|
||||
Browse
|
||||
Logout
|
||||
SetWallpaper(Int)
|
||||
SetSessionSetting(SettingChange)
|
||||
}
|
||||
///|
|
||||
/// A native file-chooser dialog (zenity on the host session) for "Add widget".
|
||||
@@ -301,7 +307,7 @@ pub fn on_event(handle : UInt, on_popup : Bool, event : @types.InputEvent) -> Bo
|
||||
/// 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).
|
||||
/// (sssi: id name path loaded), 4 instances (sss: slot module name), 5 wallpapers (s), 6 session settings (s).
|
||||
pub fn publish_table(which : UInt, rows : FixedArray[Byte]) -> Unit {
|
||||
|
||||
let ptr = mbt_ffi_bytes2ptr(rows)
|
||||
@@ -323,6 +329,13 @@ pub fn publish_wallpaper(current : Int) -> Unit {
|
||||
|
||||
wasmImportPublishWallpaper(current);
|
||||
|
||||
}
|
||||
///|
|
||||
/// Which session settings are on: bit i for row i of the session settings table.
|
||||
pub fn publish_session_settings(on : UInt) -> Unit {
|
||||
|
||||
wasmImportPublishSessionSettings((on).reinterpret_as_int());
|
||||
|
||||
}
|
||||
///|
|
||||
pub fn publish_system(s : SystemSnapshot) -> Unit {
|
||||
@@ -412,6 +425,10 @@ pub fn next_request() -> Request? {
|
||||
|
||||
Request::SetWallpaper(mbt_ffi_load32((return_area) + 8))
|
||||
}
|
||||
9 => {
|
||||
|
||||
Request::SetSessionSetting(SettingChange::{index : mbt_ffi_load32((return_area) + 8), on : (mbt_ffi_load8_u((return_area) + 12) != 0)})
|
||||
}
|
||||
_ => panic()
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user