The Panel tab was one flat list: every panel module with an "x" that removed it on any click, then every module on disk again with cryptic "x1" counts and a Browse row that looked selected. - "In the panel, left to right": the modules in panel order, each with move up / move down / remove buttons. Clicking the row itself does nothing, so a stray click no longer removes a module. Backspace/Delete removes the highlighted one, PageUp/PageDown move it. - "Add to the panel": grouped (Apps and windows, System, Clocks, Other), each with a one-line description and an Add button. A module already in the panel is left out, except clocks, which offer "Add another". With nothing left: "Everything is in the panel". - "Browse for a module file..." is a secondary outlined button. - Section headings are larger and full contrast; the popup is 320 wide and now fits a 720-high screen with the default panel. Reordering goes through a new modules.move-instance(slot, delta) capability call, plumbed through both hosts: wasmer stub request 17, host-wasm, the plasmoids host WIT (move-instance(instance-move)) and wasmhost. The shell's move_slot clamps to the ends and saves panel.edn, so the saved format is unchanged. DesktopShell::slot_popup_texts lets tests find popup rows by text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hhRDWZf5WcmrNwnFe3
This commit is contained in:
16 files changed
+514
-98
No files matched your search
@@ -342,6 +342,8 @@ pub(all) enum HostRequest {
|
||||
SetInspector(Bool)
|
||||
LoadModule(String)
|
||||
UnloadInstance(String)
|
||||
/// Move a panel instance `delta` places (negative: towards the start of the panel).
|
||||
MoveInstance(String, Int)
|
||||
Browse
|
||||
Logout
|
||||
SetWallpaper(Int)
|
||||
@@ -369,6 +371,7 @@ pub fn next_request() -> HostRequest? {
|
||||
Some(SetInspector(on)) => Some(SetInspector(on))
|
||||
Some(LoadModule(p)) => Some(LoadModule(p))
|
||||
Some(UnloadInstance(s)) => Some(UnloadInstance(s))
|
||||
Some(MoveInstance(m)) => Some(MoveInstance(m.slot, m.delta))
|
||||
Some(Browse) => Some(Browse)
|
||||
Some(Logout) => Some(Logout)
|
||||
Some(SetWallpaper(i)) => Some(SetWallpaper(i))
|
||||
|
||||
@@ -764,6 +764,8 @@ pub(all) enum HostRequest {
|
||||
SetInspector(Bool)
|
||||
LoadModule(String)
|
||||
UnloadInstance(String)
|
||||
/// Move a panel instance `delta` places (negative: towards the start of the panel).
|
||||
MoveInstance(String, Int)
|
||||
Browse
|
||||
Logout
|
||||
SetWallpaper(Int)
|
||||
@@ -797,6 +799,10 @@ pub fn next_request() -> HostRequest? {
|
||||
4 => Some(SetInspector(c_host_req_int() != 0))
|
||||
5 => Some(LoadModule(req_str()))
|
||||
6 => Some(UnloadInstance(req_str()))
|
||||
17 => {
|
||||
let delta = c_host_req_int()
|
||||
Some(MoveInstance(req_str(), delta))
|
||||
}
|
||||
7 => Some(Browse)
|
||||
8 => Some(Logout)
|
||||
9 => Some(SetWallpaper(c_host_req_int()))
|
||||
|
||||
@@ -51,7 +51,7 @@ static Inst insts[MAX_INST];
|
||||
/* Host imports a module can call. */
|
||||
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_INSPECT_IS_ON, K_INSPECT_SET, K_MOD_AVAILABLE, K_MOD_LOADED, K_MOD_LOAD, K_MOD_UNLOAD, K_MOD_MOVE, K_MOD_BROWSE,
|
||||
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,
|
||||
K_APP_ICON,
|
||||
@@ -423,6 +423,8 @@ static wasm_trap_t *host_import(void *env, const wasm_val_vec_t *args, wasm_val_
|
||||
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; }
|
||||
case K_MOD_UNLOAD: { char *s = guest_str(in, a0, a1); push_req(6, 0, s); free(s); break; }
|
||||
/* move-instance(slot, delta): request 17, delta in n. */
|
||||
case K_MOD_MOVE: { char *s = guest_str(in, a0, a1); push_req(17, a2, s); free(s); break; }
|
||||
case K_LAUNCH: {
|
||||
/* launch(id) -> result<_, string>; (ptr, len, retptr). Known catalog ids succeed; the shell spawns after the call. */
|
||||
char *id = guest_str(in, a0, a1);
|
||||
@@ -603,6 +605,7 @@ static int classify_import(const wasm_name_t *m, const wasm_name_t *f) {
|
||||
if (!strcmp(iface, "modules") && !strcmp(fn, "loaded")) return K_MOD_LOADED;
|
||||
if (!strcmp(iface, "modules") && !strcmp(fn, "load-module")) return K_MOD_LOAD;
|
||||
if (!strcmp(iface, "modules") && !strcmp(fn, "unload-instance")) return K_MOD_UNLOAD;
|
||||
if (!strcmp(iface, "modules") && !strcmp(fn, "move-instance")) return K_MOD_MOVE;
|
||||
if (!strcmp(iface, "modules") && !strcmp(fn, "browse")) return K_MOD_BROWSE;
|
||||
return K_OTHER;
|
||||
}
|
||||
|
||||
@@ -244,21 +244,29 @@ test "launcher module reads the host catalog, filters on typed keys and launches
|
||||
}
|
||||
|
||||
///|
|
||||
test "the settings module's Panel tab lists host modules and asks to load, unload and browse" {
|
||||
test "the settings module's Panel tab lists host modules and asks to load, move, unload and browse" {
|
||||
let p = load_module("session-settings")
|
||||
assert_true(p.imports().contains("modules"))
|
||||
let av = Table::new()
|
||||
av.str("moon-disc")
|
||||
av.str("Moon Phase (disc)")
|
||||
av.str("/m/moon-disc.wasm")
|
||||
av.int(0)
|
||||
av.end_row()
|
||||
for m in [
|
||||
("moon-disc", "Moon Phase (disc)", "/m/moon-disc.wasm", 0),
|
||||
("tasks", "Task Manager", "/m/tasks.wasm", 1),
|
||||
("clock-digital", "Digital Clock", "/m/clock-digital.wasm", 1),
|
||||
] {
|
||||
av.str(m.0)
|
||||
av.str(m.1)
|
||||
av.str(m.2)
|
||||
av.int(m.3)
|
||||
av.end_row()
|
||||
}
|
||||
publish(Modules, av)
|
||||
let li = Table::new()
|
||||
li.str("w1")
|
||||
li.str("clock-digital")
|
||||
li.str("Digital Clock")
|
||||
li.end_row()
|
||||
for i in [("w1", "clock-digital", "Digital Clock"), ("w2", "tasks", "Task Manager")] {
|
||||
li.str(i.0)
|
||||
li.str(i.1)
|
||||
li.str(i.2)
|
||||
li.end_row()
|
||||
}
|
||||
publish(Instances, li)
|
||||
assert_true(p.on_event(false, PointerDown(1, 1)))
|
||||
assert_true(p.on_event(true, KeyDown("3"))) // the Panel tab
|
||||
@@ -266,15 +274,35 @@ test "the settings module's Panel tab lists host modules and asks to load, unloa
|
||||
None => fail("popup should be open")
|
||||
Some(ps) => {
|
||||
let ts = texts_of(ps.ops)
|
||||
assert_true(ts.contains("Digital Clock"))
|
||||
assert_true(ts.contains("Moon Phase (disc)"))
|
||||
assert_true(ts.contains("Clocks"))
|
||||
// The task manager is in the panel and one is enough: it is not offered again. A clock
|
||||
// can go in twice, so it is.
|
||||
assert_eq(ts.filter(t => t == "Task Manager").length(), 1)
|
||||
assert_eq(ts.filter(t => t == "Digital Clock").length(), 2)
|
||||
assert_true(ts.contains("Add another"))
|
||||
assert_false(ts.contains("x1"))
|
||||
}
|
||||
}
|
||||
// Below the tab bar (40), rows of 28: heading, loaded, heading, available, browse.
|
||||
ignore(p.on_event(true, PointerDown(20, 40 + 28 + 3)))
|
||||
ignore(p.on_event(true, PointerDown(20, 40 + 3 * 28 + 3)))
|
||||
ignore(p.on_event(true, PointerDown(20, 40 + 4 * 28 + 3)))
|
||||
assert_eq(drain(), [UnloadInstance("w1"), LoadModule("/m/moon-disc.wasm"), Browse])
|
||||
// Below the tab bar (40): heading (28), the two panel rows (30 each, buttons up at x 222-246,
|
||||
// down 248-272, remove 284-308), heading (28), "Clocks" (22), two Add rows (42 each), Browse.
|
||||
ignore(p.on_event(true, PointerDown(20, 82))) // w1's row itself: nothing
|
||||
ignore(p.on_event(true, PointerDown(234, 82))) // w1 is first: up does nothing
|
||||
ignore(p.on_event(true, PointerDown(260, 82))) // down
|
||||
ignore(p.on_event(true, PointerDown(296, 112))) // w2's remove
|
||||
ignore(p.on_event(true, PointerDown(20, 190))) // add the moon
|
||||
ignore(p.on_event(true, PointerDown(160, 285))) // browse
|
||||
assert_eq(drain(), [
|
||||
MoveInstance("w1", 1),
|
||||
UnloadInstance("w2"),
|
||||
LoadModule("/m/moon-disc.wasm"),
|
||||
Browse,
|
||||
])
|
||||
// Keys: Backspace removes the highlighted panel module, PageUp moves it.
|
||||
ignore(p.on_event(true, PointerMove(20, 112)))
|
||||
assert_true(p.on_event(true, KeyDown("PageUp")))
|
||||
assert_true(p.on_event(true, KeyDown("Backspace")))
|
||||
assert_eq(drain(), [MoveInstance("w2", -1), UnloadInstance("w1")])
|
||||
p.unload()
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user