Settings > Panel: a cleaner module selector with reordering
CI / test (push) Failing after 17s

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:
Claude committed 2026-11-25 20:35:54 +00:00
1 parent c1936299cb
commit 8ecdef17d4
16 files changed
+512 -96

No files matched your search

@@ -6,20 +6,23 @@
/// - Desktop: what is drawn on the desktop. Today that is the wallpaper (`wallpaper.wallpapers`, /// - Desktop: what is drawn on the desktop. Today that is the wallpaper (`wallpaper.wallpapers`,
/// the current one ticked); modules can't be placed on the desktop yet, so when they can they /// the current one ticked); modules can't be placed on the desktop yet, so when they can they
/// get their own section here; /// get their own section here;
/// - Panel: the modules in the panel (click to remove), every module found on the search path /// - Panel: the modules in the panel in panel order (left to right), each with move-up/down and
/// (click to add another instance) and "Browse..." (`modules`). The panel menu's "Modules..." /// remove buttons; then the modules that can be added, grouped by kind with a short description
/// opens this tab; /// and an Add button (a module already in the panel is left out unless more than one makes
/// sense, like a clock); and a "Browse for a module file..." button (`modules`). The panel
/// menu's "Modules..." opens this tab;
/// - Power: the battery (`system`, when there is one), how long without input before the screen /// - Power: the battery (`system`, when there is one), how long without input before the screen
/// turns off and before the computer suspends (a click steps through the choices), and Suspend, /// turns off and before the computer suspends (a click steps through the choices), and Suspend,
/// Restart and Power off now (`power`); Restart and Power off ask for a second click. /// Restart and Power off now (`power`); Restart and Power off ask for a second click.
/// ///
/// Clicking a row acts at once and the popup stays open. Up/Down move the highlight, Left/Right /// Clicking a row acts at once and the popup stays open; a row in the panel list only acts through
/// (or 1-4) switch tabs, Enter or Space acts on the highlighted row, Escape or a click /// its buttons, so a stray click doesn't remove anything. Up/Down move the highlight, Left/Right
/// elsewhere closes. The shell remembers settings and wallpaper in state.edn, the panel in /// (or 1-4) switch tabs, Enter or Space acts on the highlighted row, Backspace or Delete removes
/// the highlighted panel module and PageUp/PageDown move it, Escape or a click elsewhere closes. The shell remembers settings and wallpaper in state.edn, the panel in
/// panel.edn. /// panel.edn.
///| Popup geometry: the tab bar, then a column of rows, with a margin around them. ///| Popup geometry: the tab bar, then a column of rows, with a margin around them.
let popup_w : Int = 300 let popup_w : Int = 320
///| ///|
let margin : Int = 6 let margin : Int = 6
@@ -27,7 +30,8 @@ let margin : Int = 6
///| ///|
let tab_h : Int = 30 let tab_h : Int = 30
///| Top of the first row (below the tab bar). ///| Top of the first row (below the tab bar). Rows are `row_h` tall except on the Panel tab (see
/// `row_height`).
let rows_top : Int = 40 let rows_top : Int = 40
///| ///|
@@ -47,10 +51,14 @@ enum Row {
Heading(String) Heading(String)
Setting(Int, String) Setting(Int, String)
Wallpaper(Int, String) Wallpaper(Int, String)
/// A loaded panel instance: slot and name. /// A group of modules in the Add list ("Clocks").
Loaded(String, String) Category(String)
/// A module on the search path: path, name and how many instances are loaded. /// A loaded panel instance: slot, name, its place in the panel and how many there are.
Available(String, String, UInt) Loaded(String, String, Int, Int)
/// A module that can be added: path, name, description and how many instances are loaded.
Available(String, String, String, UInt)
/// Every module is in the panel already.
NothingToAdd
Browse Browse
/// A line of text (the battery). /// A line of text (the battery).
Info(String) Info(String)
@@ -100,6 +108,45 @@ let tab : Ref[Int] = { val: 0 }
///| ///|
let hover : Ref[Int] = { val: -1 } let hover : Ref[Int] = { val: -1 }
///| The groups of the Add list, in order.
let categories : Array[String] = ["Apps and windows", "System", "Clocks", "Other"]
///| Which group a module (by id, its file stem) belongs to; modules we don't know go in "Other".
fn category_of(id : String) -> String {
match id {
"launcher" | "dock" | "tasks" | "layout" => "Apps and windows"
"session-settings" | "network" | "battery" | "screenshot" | "logout" => "System"
"clock-digital" | "clock-binary" | "moon-disc" => "Clocks"
_ => "Other"
}
}
///| One line on what a module does ("" for modules we don't know).
fn description_of(id : String) -> String {
match id {
"launcher" => "Search and start apps"
"dock" => "Pinned apps, one click away"
"tasks" => "Your open windows"
"layout" => "Switch tiling and floating"
"session-settings" => "This settings window"
"network" => "Wi-Fi and wired network"
"battery" => "Charge and time left"
"screenshot" => "Capture or record the screen"
"logout" => "End the session"
"clock-digital" => "The time, 12 or 24-hour"
"clock-binary" => "The time in binary"
"moon-disc" => "Tonight's moon phase"
"inspector" => "Inspect the shell's interface"
_ => ""
}
}
///| Whether more than one of a module makes sense in the panel; the others leave the Add list
/// once they are in the panel.
fn allows_many(id : String) -> Bool {
id.has_prefix("clock-")
}
///| The rows of the current tab, read live from the host (loading a module changes them). ///| The rows of the current tab, read live from the host (loading a module changes them).
fn rows() -> Array[Row] { fn rows() -> Array[Row] {
let rs : Array[Row] = [] let rs : Array[Row] = []
@@ -133,13 +180,30 @@ fn rows() -> Array[Row] {
rs.push(PowerNow(1, "Power off")) rs.push(PowerNow(1, "Power off"))
} }
_ => { _ => {
rs.push(Heading("In the panel (click to remove)")) rs.push(Heading("In the panel, left to right"))
for inst in @modules.loaded() { let loaded = @modules.loaded()
rs.push(Loaded(inst.slot, inst.name)) for i = 0; i < loaded.length(); i = i + 1 {
rs.push(Loaded(loaded[i].slot, loaded[i].name, i, loaded.length()))
} }
rs.push(Heading("Add to the panel")) rs.push(Heading("Add to the panel"))
for m in @modules.available() { let avail = @modules.available()
rs.push(Available(m.path, m.name, m.loaded)) let mut any = false
for cat in categories {
let mut first = true
for m in avail {
if category_of(m.id) != cat || (m.loaded > 0U && !allows_many(m.id)) {
continue
}
if first {
rs.push(Category(cat))
first = false
}
rs.push(Available(m.path, m.name, description_of(m.id), m.loaded))
any = true
}
}
if !any {
rs.push(NothingToAdd)
} }
rs.push(Browse) rs.push(Browse)
} }
@@ -149,7 +213,7 @@ fn rows() -> Array[Row] {
///| Whether row `i` of `rs` can be highlighted and acted on (headings can't). ///| Whether row `i` of `rs` can be highlighted and acted on (headings can't).
fn active(rs : Array[Row], i : Int) -> Bool { fn active(rs : Array[Row], i : Int) -> Bool {
i >= 0 && i < rs.length() && !(rs[i] is (Heading(_) | Info(_))) i >= 0 && i < rs.length() && !(rs[i] is (Heading(_) | Info(_) | Category(_) | NothingToAdd))
} }
///| First active row of `rs`, or -1. ///| First active row of `rs`, or -1.
@@ -176,25 +240,100 @@ fn tab_w() -> Int {
(popup_w - 2 * margin) / tab_names.length() (popup_w - 2 * margin) / tab_names.length()
} }
///| Height of a row: the Panel tab's rows vary (two-line Add rows, slim group labels); every
/// other row is `row_h`.
fn row_height(r : Row) -> Int {
match r {
Loaded(_, _, _, _) => loaded_h
Category(_) => category_h
Available(_, _, _, _) => available_h
Browse => browse_h
_ => row_h
}
}
///|
let loaded_h : Int = 30
///|
let category_h : Int = 22
///|
let available_h : Int = 42
///|
let browse_h : Int = 44
///| Top of each row, popup-local.
fn row_tops(rs : Array[Row]) -> Array[Int] {
let tops = []
let mut y = rows_top
for r in rs {
tops.push(y)
y = y + row_height(r)
}
tops
}
///| Row under a popup-local point, or -1 (headings count as none). ///| Row under a popup-local point, or -1 (headings count as none).
fn row_at(rs : Array[Row], x : Int, y : Int) -> Int { fn row_at(rs : Array[Row], x : Int, y : Int) -> Int {
if x < margin || x >= popup_w - margin || y < rows_top { if x < margin || x >= popup_w - margin || y < rows_top {
return -1 return -1
} }
let i = (y - rows_top) / row_h let tops = row_tops(rs)
if active(rs, i) { i } else { -1 } for i = 0; i < rs.length(); i = i + 1 {
if y >= tops[i] && y < tops[i] + row_height(rs[i]) {
return if active(rs, i) { i } else { -1 }
}
}
-1
} }
///| ///|
fn popup_h(n : Int) -> Int { fn popup_h(rs : Array[Row]) -> Int {
rows_top + n * row_h + margin let mut h = rows_top + margin
for r in rs {
h = h + row_height(r)
} }
h
}
///| The small buttons at the right end of a panel-list row, popup-local: move up, move down,
/// remove.
let btn_size : Int = 24
///|
fn loaded_button(k : Int, top : Int) -> @types.Rect {
// Remove sits apart from the two move buttons.
let right = popup_w - margin - 6
let x = match k {
2 => right - btn_size
1 => right - btn_size - 12 - btn_size
_ => right - btn_size - 12 - 2 * btn_size - 2
}
@ui.rect(x, top + (loaded_h - 2 - btn_size) / 2, btn_size, btn_size)
}
///| Which button of a panel-list row is under popup-local `x`/`y` (0 up, 1 down, 2 remove), or -1.
fn loaded_button_at(top : Int, x : Int, y : Int) -> Int {
for k = 0; k < 3; k = k + 1 {
let b = loaded_button(k, top)
if x >= b.x && x < b.x + @ui.rect_w(b) && y >= b.y && y < b.y + @ui.rect_h(b) {
return k
}
}
-1
}
///| The button under the pointer in the highlighted row (-1: none).
let hover_btn : Ref[Int] = { val: -1 }
///| ///|
fn set_tab(i : Int) -> Unit { fn set_tab(i : Int) -> Unit {
tab.val = i tab.val = i
armed.val = -1 armed.val = -1
hover.val = first_active(rows()) hover.val = first_active(rows())
hover_btn.val = -1
} }
///| ///|
@@ -204,8 +343,9 @@ fn close() -> Unit {
hover.val = -1 hover.val = -1
} }
///| Act on row `i`: flip a setting, show a wallpaper, unload or load a module, or browse. ///| Act on row `i`: flip a setting, show a wallpaper, load a module, or browse. A panel-list row
fn act(rs : Array[Row], i : Int) -> Unit { /// acts only through button `btn` (0 move up, 1 move down, 2 remove).
fn act(rs : Array[Row], i : Int, btn~ : Int = -1) -> Unit {
if !active(rs, i) { if !active(rs, i) {
return return
} }
@@ -232,10 +372,16 @@ fn act(rs : Array[Row], i : Int) -> Unit {
@settings.set_setting(idx, !@settings.is_on(idx)) @settings.set_setting(idx, !@settings.is_on(idx))
} }
Wallpaper(k, _) => @wallpaper.set_wallpaper(k.reinterpret_as_uint()) Wallpaper(k, _) => @wallpaper.set_wallpaper(k.reinterpret_as_uint())
Loaded(slot, _) => @modules.unload_instance(slot) Loaded(slot, _, idx, n) =>
Available(path, _, _) => @modules.load_module(path) match btn {
0 => if idx > 0 { @modules.move_instance(slot, -1) }
1 => if idx < n - 1 { @modules.move_instance(slot, 1) }
2 => @modules.unload_instance(slot)
_ => ()
}
Available(path, _, _, _) => @modules.load_module(path)
Browse => @modules.browse() Browse => @modules.browse()
Heading(_) => () Heading(_) | Category(_) | NothingToAdd => ()
} }
} }
@@ -295,7 +441,8 @@ pub fn popup() -> PopupSurface? {
let p = t.palette let p = t.palette
let rs = rows() let rs = rows()
let w = popup_w let w = popup_w
let h = popup_h(rs.length()) let h = popup_h(rs)
let tops = row_tops(rs)
let r = t.radius.reinterpret_as_int() let r = t.radius.reinterpret_as_int()
let fs = t.font_size.reinterpret_as_int() let fs = t.font_size.reinterpret_as_int()
let ops : Array[@types.DrawOp] = [ let ops : Array[@types.DrawOp] = [
@@ -316,24 +463,29 @@ pub fn popup() -> PopupSurface? {
ops.push(@ui.line(margin, rows_top - 3, w - margin, rows_top - 3, p.border, width=1)) ops.push(@ui.line(margin, rows_top - 3, w - margin, rows_top - 3, p.border, width=1))
let cur_wall = @wallpaper.current_wallpaper().reinterpret_as_int() let cur_wall = @wallpaper.current_wallpaper().reinterpret_as_int()
for i = 0; i < rs.length(); i = i + 1 { for i = 0; i < rs.length(); i = i + 1 {
let y = rows_top + i * row_h let y = tops[i]
let mid = y + (row_h - 2) / 2 let rh = row_height(rs[i])
let mid = y + (rh - 2) / 2
let hot = i == hover.val let hot = i == hover.val
// Hover: a soft fill behind switches, the accent behind list rows. // Hover: a soft fill behind switches, the accent behind list rows.
let list_fg = if hot { p.accent_foreground } else { p.foreground } let list_fg = if hot { p.accent_foreground } else { p.foreground }
match rs[i] { match rs[i] {
Heading(_) => () Heading(_) | Category(_) | NothingToAdd | Browse => ()
Setting(_, _) => // Rows with their own buttons get the soft fill, so the buttons stand out.
Setting(_, _) | Loaded(_, _, _, _) | Available(_, _, _, _) =>
if hot { if hot {
ops.push(@ui.fill_rect(@ui.rect(margin, y, w - 2 * margin, row_h - 2), p.surface_hover, radius=r)) ops.push(@ui.fill_rect(@ui.rect(margin, y, w - 2 * margin, rh - 2), p.surface_hover, radius=r))
} }
Info(_) => ()
_ => _ =>
if hot { if hot {
ops.push(@ui.fill_rect(@ui.rect(margin, y, w - 2 * margin, row_h - 2), p.accent, radius=r)) ops.push(@ui.fill_rect(@ui.rect(margin, y, w - 2 * margin, rh - 2), p.accent, radius=r))
} }
} }
match rs[i] { match rs[i] {
Heading(label) => ops.push(@ui.text(margin + 8, mid, label, fs - 3, p.foreground_muted, bold=true)) Heading(label) => ops.push(@ui.text(margin + 8, mid + 2, label, fs - 1, p.foreground, bold=true))
Category(label) => ops.push(@ui.text(margin + 10, mid, label, fs - 3, p.foreground_muted, bold=true))
NothingToAdd => ops.push(@ui.text(margin + 10, mid, "Everything is in the panel", fs - 2, p.foreground_muted))
Setting(k, name) => { Setting(k, name) => {
ops.push(@ui.text(margin + 10, mid, name, fs - 1, p.foreground)) ops.push(@ui.text(margin + 10, mid, name, fs - 1, p.foreground))
// The switch: an accent track with the knob on the right when on, a muted outline when off. // The switch: an accent track with the knob on the right when on, a muted outline when off.
@@ -357,17 +509,83 @@ pub fn popup() -> PopupSurface? {
} }
ops.push(@ui.text(margin + 26, mid, name, fs - 1, list_fg, bold=k == cur_wall)) ops.push(@ui.text(margin + 26, mid, name, fs - 1, list_fg, bold=k == cur_wall))
} }
Loaded(_, name) => { Loaded(_, name, idx, n) => {
ops.push(@ui.text(margin + 10, mid, name, fs - 1, list_fg)) ops.push(@ui.text(margin + 10, mid, name, fs - 1, p.foreground))
ops.push(@ui.text(w - margin - 10, mid, "x", fs - 1, list_fg, align=RIGHT, bold=true)) for k = 0; k < 3; k = k + 1 {
let enabled = match k {
0 => idx > 0
1 => idx < n - 1
_ => true
} }
Available(_, name, n) => { let b = loaded_button(k, y)
ops.push(@ui.text(margin + 10, mid, name, fs - 1, list_fg)) let bx = b.x
if n > 0U { let by = b.y
ops.push(@ui.text(w - margin - 10, mid, "x" + n.to_string(), fs - 3, list_fg, align=RIGHT)) let cx = bx + btn_size / 2
let cy = by + btn_size / 2
let btn_hot = hot && hover_btn.val == k && enabled
if btn_hot {
ops.push(@ui.fill_rect(b, p.accent, radius=r))
}
let ic = if btn_hot {
p.accent_foreground
} else if !enabled {
@ui.with_alpha(p.foreground_muted, 40)
} else if hot {
p.foreground
} else {
p.foreground_muted
}
match k {
0 => {
ops.push(@ui.line(cx - 5, cy + 2, cx, cy - 3, ic, width=2))
ops.push(@ui.line(cx, cy - 3, cx + 5, cy + 2, ic, width=2))
}
1 => {
ops.push(@ui.line(cx - 5, cy - 2, cx, cy + 3, ic, width=2))
ops.push(@ui.line(cx, cy + 3, cx + 5, cy - 2, ic, width=2))
}
_ => {
ops.push(@ui.line(cx - 4, cy - 4, cx + 4, cy + 4, ic, width=2))
ops.push(@ui.line(cx - 4, cy + 4, cx + 4, cy - 4, ic, width=2))
} }
} }
Browse => ops.push(@ui.text(margin + 10, mid, "Browse...", fs - 1, list_fg, bold=true)) }
}
Available(_, name, desc, n) => {
if desc == "" {
ops.push(@ui.text(margin + 10, mid, name, fs - 1, p.foreground))
} else {
ops.push(@ui.text(margin + 10, y + 13, name, fs - 1, p.foreground))
ops.push(@ui.text(margin + 10, y + 29, desc, fs - 3, p.foreground_muted))
}
// The Add button: outlined, filled with the accent while its row is highlighted.
let label = if n > 0U { "Add another" } else { "Add" }
let bw = @ui.text_width(label, fs - 2) + 20
let bh = 24
let bx = w - margin - 8 - bw
let by = mid - bh / 2
if hot {
ops.push(@ui.fill_rect(@ui.rect(bx, by, bw, bh), p.accent, radius=bh / 2))
} else {
ops.push(@ui.stroke_rect(@ui.rect(bx, by, bw, bh), p.accent, width=1, radius=bh / 2))
}
let bfg = if hot { p.accent_foreground } else { p.accent }
ops.push(@ui.text(bx + bw / 2, mid, label, fs - 2, bfg, align=CENTER, bold=true))
}
Browse => {
// A secondary button below the list: an outline, softly filled while highlighted.
ops.push(@ui.line(margin + 4, y + 2, w - margin - 4, y + 2, p.border, width=1))
let label = "Browse for a module file..."
let bw = @ui.text_width(label, fs - 2) + 28
let bh = 28
let bx = (w - bw) / 2
let by = y + 9
if hot {
ops.push(@ui.fill_rect(@ui.rect(bx, by, bw, bh), p.surface_hover, radius=r))
}
ops.push(@ui.stroke_rect(@ui.rect(bx, by, bw, bh), if hot { p.accent } else { p.border }, width=1, radius=r))
ops.push(@ui.text(w / 2, by + bh / 2, label, fs - 2, if hot { p.foreground } else { p.foreground_muted }, align=CENTER))
}
Info(text) => ops.push(@ui.text(margin + 10, mid, text, fs - 1, p.foreground)) Info(text) => ops.push(@ui.text(margin + 10, mid, text, fs - 1, p.foreground))
Timeout(k, label) => { Timeout(k, label) => {
let m = if k == 0 { @power.screen_off_minutes() } else { @power.suspend_minutes() } let m = if k == 0 { @power.screen_off_minutes() } else { @power.suspend_minutes() }
@@ -396,9 +614,16 @@ pub fn on_event(target : Surface, event : @types.InputEvent) -> Bool {
true true
} }
(POPUP, PointerMove(p)) => { (POPUP, PointerMove(p)) => {
let i = row_at(rows(), p.x, p.y) let rs = rows()
if i != hover.val && i >= 0 { let i = row_at(rs, p.x, p.y)
let b = if i >= 0 && rs[i] is Loaded(_, _, _, _) {
loaded_button_at(row_tops(rs)[i], p.x, p.y)
} else {
-1
}
if i >= 0 && (i != hover.val || b != hover_btn.val) {
hover.val = i hover.val = i
hover_btn.val = b
true true
} else { } else {
false false
@@ -415,10 +640,26 @@ pub fn on_event(target : Surface, event : @types.InputEvent) -> Bool {
let rs = rows() let rs = rows()
let i = row_at(rs, p.x, p.y) let i = row_at(rs, p.x, p.y)
if i >= 0 { if i >= 0 {
act(rs, i) let btn = if rs[i] is Loaded(_, _, _, _) {
loaded_button_at(row_tops(rs)[i], p.x, p.y)
} else {
-1
}
act(rs, i, btn~)
// A module list changes length: keep the highlight on a real row. // A module list changes length: keep the highlight on a real row.
let after = rows() let after = rows()
hover.val = if active(after, i) { i } else { first_active(after) } hover.val = if active(after, i) { i } else { first_active(after) }
// A moved module: keep the highlight on it, under the pointer's button.
match rs[i] {
Loaded(_, _, idx, n) =>
if btn == 0 && idx > 0 {
hover.val = i - 1
} else if btn == 1 && idx < n - 1 {
hover.val = i + 1
}
_ => ()
}
hover_btn.val = -1
} }
true true
} }
@@ -443,6 +684,25 @@ pub fn on_event(target : Surface, event : @types.InputEvent) -> Bool {
hover.val = first_active(after) hover.val = first_active(after)
} }
true true
} else if k == "Backspace" || k == "Delete" || k == "PageUp" || k == "PageDown" {
let rs = rows()
match (if active(rs, hover.val) { Some(rs[hover.val]) } else { None }) {
Some(Loaded(_, _, idx, n)) => {
let btn = if k == "PageUp" { 0 } else if k == "PageDown" { 1 } else { 2 }
act(rs, hover.val, btn~)
if btn == 0 && idx > 0 {
hover.val = hover.val - 1
} else if btn == 1 && idx < n - 1 {
hover.val = hover.val + 1
}
let after = rows()
if !active(after, hover.val) {
hover.val = first_active(after)
}
true
}
_ => false
}
} else if k == "ArrowDown" || k == "Down" { } else if k == "ArrowDown" || k == "Down" {
move_hover(1) move_hover(1)
true true
+42 -21
View File
@@ -596,34 +596,55 @@ test "the wasm picker opens the settings module's Panel tab, which loads and unl
ignore(comp.compose_frame()) ignore(comp.compose_frame())
let pr = comp.shell.slot_popup_rect(mgr) let pr = comp.shell.slot_popup_rect(mgr)
assert_true(pr.w > 0) // the picker opened the popup assert_true(pr.w > 0) // the picker opened the popup
// Rows below the tab bar (40): heading, one per loaded module, heading, one per available // Find rows by their text: the y of the first (or last) line reading `label`.
// module, browse; 28 each. let row_y = fn(label : String, last : Bool) -> Int {
let mut y = -1
for t in comp.shell.slot_popup_texts(mgr) {
if t.0 == label && (last || y < 0) {
y = t.2
}
}
y
}
let texts = comp.shell.slot_popup_texts(mgr).map(t => t.0)
assert_true(texts.contains("In the panel, left to right"))
assert_true(texts.contains("Add to the panel"))
assert_true(texts.contains("Browse for a module file..."))
// The Add list leaves out what is already in the panel (but a clock can be added twice) and
// has no cryptic instance counts.
assert_eq(texts.filter(t => t == "Task Manager").length(), 1)
assert_false(texts.contains("x1"))
assert_true(texts.contains("Pinned apps, one click away")) // the Dock's description
let loaded = comp.shell.slots().length() let loaded = comp.shell.slots().length()
assert_true(pr.h >= 40 + (loaded + 3) * 28)
let avail_y = fn(pr : @scene.Rect, k : Int) { pr.y + 40 + (loaded + 2 + k) * 28 + 13 }
let mut k_bin = -1
for k = 0; k < comp.shell.catalog.length(); k = k + 1 {
if comp.shell.catalog[k].id == "clock-binary" {
k_bin = k
}
}
assert_true(k_bin >= 0)
assert_eq(comp.shell.slot_of("clock-binary"), "") assert_eq(comp.shell.slot_of("clock-binary"), "")
click_at(comp, pr.x + 40, avail_y(pr, k_bin), 20U) // select it: it is loaded into the panel let by = row_y("Binary Clock", false)
assert_true(by > 0)
click_at(comp, pr.x + 40, pr.y + by, 20U) // its Add row: it is loaded into the panel
assert_true(comp.shell.slot_of("clock-binary") != "") assert_true(comp.shell.slot_of("clock-binary") != "")
assert_eq(comp.shell.slots().length(), loaded + 1) assert_eq(comp.shell.slots().length(), loaded + 1)
// The popup stays open (it grew a row); click the loaded module's row to unload it again.
ignore(comp.compose_frame()) ignore(comp.compose_frame())
// A clock can go in twice, so it stays in the Add list, offered as another one.
assert_true(comp.shell.slot_popup_texts(mgr).map(t => t.0).contains("Add another"))
let pr2 = comp.shell.slot_popup_rect(mgr) let pr2 = comp.shell.slot_popup_rect(mgr)
assert_true(pr2.w > 0) assert_true(pr2.w > 0) // the popup stays open
let bin = comp.shell.slot_of("clock-binary")
let ly = row_y("Binary Clock", false) // now the panel list's row comes first
// Clicking the row itself does nothing: only its buttons act.
click_at(comp, pr2.x + 40, pr2.y + ly, 30U)
assert_eq(comp.shell.slot_of("clock-binary"), bin)
// It was added at the end; move it up one place with the up button.
let slots = comp.shell.slots() let slots = comp.shell.slots()
let mut idx = -1 assert_eq(slots[slots.length() - 1], bin)
for i = 0; i < slots.length(); i = i + 1 { click_at(comp, pr2.x + pr2.w - 86, pr2.y + ly, 40U)
if slots[i] == comp.shell.slot_of("clock-binary") { let moved = comp.shell.slots()
idx = i assert_eq(moved[moved.length() - 2], bin)
} assert_eq(moved.length(), slots.length())
} // Then remove it with its x button (its row moved up one place).
click_at(comp, pr2.x + 40, pr2.y + 40 + (1 + idx) * 28 + 13, 30U) ignore(comp.compose_frame())
let pr3 = comp.shell.slot_popup_rect(mgr)
let ly3 = row_y("Binary Clock", false)
assert_true(ly3 < ly)
click_at(comp, pr3.x + pr3.w - 24, pr3.y + ly3, 50U)
assert_eq(comp.shell.slot_of("clock-binary"), "") assert_eq(comp.shell.slot_of("clock-binary"), "")
assert_eq(comp.shell.slots().length(), loaded) assert_eq(comp.shell.slots().length(), loaded)
// The settings module is just another module: it can be removed too, and the picker brings it // The settings module is just another module: it can be removed too, and the picker brings it
+46
View File
@@ -359,6 +359,34 @@ pub fn DesktopShell::unload_slot(self : DesktopShell, slot : String) -> Bool {
} }
} }
///| Move the module in `slot` `delta` places along the panel (clamped to either end) and save
/// the new order. False when there is no such slot or it is already at that end.
pub fn DesktopShell::move_slot(self : DesktopShell, slot : String, delta : Int) -> Bool {
let mut idx = -1
for i = 0; i < self.widgets.length(); i = i + 1 {
if self.widgets[i].slot == slot {
idx = i
}
}
if idx < 0 {
return false
}
let mut to = idx + delta
if to < 0 {
to = 0
}
if to > self.widgets.length() - 1 {
to = self.widgets.length() - 1
}
if to == idx {
return false
}
let w = self.widgets.remove(idx)
self.widgets.insert(to, w)
self.save_panel_config()
true
}
///| Replace the module in `slot` with the module file at `path`, keeping its place in the panel. ///| Replace the module in `slot` with the module file at `path`, keeping its place in the panel.
pub fn DesktopShell::replace_slot(self : DesktopShell, slot : String, path : String) -> Bool { pub fn DesktopShell::replace_slot(self : DesktopShell, slot : String, path : String) -> Bool {
let mut idx = -1 let mut idx = -1
@@ -438,6 +466,23 @@ pub fn DesktopShell::slot_popup_rect(self : DesktopShell, slot : String) -> @sce
} }
} }
///| The text drawn in `slot`'s open popup, with each line's popup-local origin, in drawing
/// order (empty when the popup is closed). Lets tests find a row without knowing the layout.
pub fn DesktopShell::slot_popup_texts(self : DesktopShell, slot : String) -> Array[(String, Int, Int)] {
let out = []
match self.widget_by_slot(slot) {
Some(w) =>
for op in w.popup_ops {
match op {
Text(t) => out.push((t.text, t.origin.x, t.origin.y))
_ => ()
}
}
None => ()
}
out
}
///| Publish what modules can read through their capabilities (apps, windows, layout, loaded modules). ///| Publish what modules can read through their capabilities (apps, windows, layout, loaded modules).
fn DesktopShell::publish_host_data(self : DesktopShell) -> Unit { fn DesktopShell::publish_host_data(self : DesktopShell) -> Unit {
if self.apps_dirty { if self.apps_dirty {
@@ -624,6 +669,7 @@ fn DesktopShell::process_requests(self : DesktopShell) -> Unit {
} }
} }
Some(UnloadInstance(slot)) => ignore(self.unload_slot(slot)) Some(UnloadInstance(slot)) => ignore(self.unload_slot(slot))
Some(MoveInstance(slot, delta)) => ignore(self.move_slot(slot, delta))
Some(Browse) => Some(Browse) =>
if self.picker is None { if self.picker is None {
self.picker = @wasm.Picker::start() self.picker = @wasm.Picker::start()
+3
View File
@@ -342,6 +342,8 @@ pub(all) enum HostRequest {
SetInspector(Bool) SetInspector(Bool)
LoadModule(String) LoadModule(String)
UnloadInstance(String) UnloadInstance(String)
/// Move a panel instance `delta` places (negative: towards the start of the panel).
MoveInstance(String, Int)
Browse Browse
Logout Logout
SetWallpaper(Int) SetWallpaper(Int)
@@ -369,6 +371,7 @@ pub fn next_request() -> HostRequest? {
Some(SetInspector(on)) => Some(SetInspector(on)) Some(SetInspector(on)) => Some(SetInspector(on))
Some(LoadModule(p)) => Some(LoadModule(p)) Some(LoadModule(p)) => Some(LoadModule(p))
Some(UnloadInstance(s)) => Some(UnloadInstance(s)) Some(UnloadInstance(s)) => Some(UnloadInstance(s))
Some(MoveInstance(m)) => Some(MoveInstance(m.slot, m.delta))
Some(Browse) => Some(Browse) Some(Browse) => Some(Browse)
Some(Logout) => Some(Logout) Some(Logout) => Some(Logout)
Some(SetWallpaper(i)) => Some(SetWallpaper(i)) Some(SetWallpaper(i)) => Some(SetWallpaper(i))
+6
View File
@@ -764,6 +764,8 @@ pub(all) enum HostRequest {
SetInspector(Bool) SetInspector(Bool)
LoadModule(String) LoadModule(String)
UnloadInstance(String) UnloadInstance(String)
/// Move a panel instance `delta` places (negative: towards the start of the panel).
MoveInstance(String, Int)
Browse Browse
Logout Logout
SetWallpaper(Int) SetWallpaper(Int)
@@ -797,6 +799,10 @@ pub fn next_request() -> HostRequest? {
4 => Some(SetInspector(c_host_req_int() != 0)) 4 => Some(SetInspector(c_host_req_int() != 0))
5 => Some(LoadModule(req_str())) 5 => Some(LoadModule(req_str()))
6 => Some(UnloadInstance(req_str())) 6 => Some(UnloadInstance(req_str()))
17 => {
let delta = c_host_req_int()
Some(MoveInstance(req_str(), delta))
}
7 => Some(Browse) 7 => Some(Browse)
8 => Some(Logout) 8 => Some(Logout)
9 => Some(SetWallpaper(c_host_req_int())) 9 => Some(SetWallpaper(c_host_req_int()))
+4 -1
View File
@@ -51,7 +51,7 @@ static Inst insts[MAX_INST];
/* Host imports a module can call. */ /* Host imports a module can call. */
enum { enum {
K_OTHER, K_TOKENS, K_CLOCK, K_APPS, K_LAUNCH, K_WINDOWS, K_FOCUS, K_LAYOUTS, K_LAYOUT_CUR, K_SET_LAYOUT, 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_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_SESSION_SETTINGS, K_SESSION_IS_ON, K_SESSION_SET,
K_APP_ICON, 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_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_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; } 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: { case K_LAUNCH: {
/* launch(id) -> result<_, string>; (ptr, len, retptr). Known catalog ids succeed; the shell spawns after the call. */ /* launch(id) -> result<_, string>; (ptr, len, retptr). Known catalog ids succeed; the shell spawns after the call. */
char *id = guest_str(in, a0, a1); 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, "loaded")) return K_MOD_LOADED;
if (!strcmp(iface, "modules") && !strcmp(fn, "load-module")) return K_MOD_LOAD; 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, "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; if (!strcmp(iface, "modules") && !strcmp(fn, "browse")) return K_MOD_BROWSE;
return K_OTHER; return K_OTHER;
} }
+42 -14
View File
@@ -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") let p = load_module("session-settings")
assert_true(p.imports().contains("modules")) assert_true(p.imports().contains("modules"))
let av = Table::new() let av = Table::new()
av.str("moon-disc") for m in [
av.str("Moon Phase (disc)") ("moon-disc", "Moon Phase (disc)", "/m/moon-disc.wasm", 0),
av.str("/m/moon-disc.wasm") ("tasks", "Task Manager", "/m/tasks.wasm", 1),
av.int(0) ("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() av.end_row()
}
publish(Modules, av) publish(Modules, av)
let li = Table::new() let li = Table::new()
li.str("w1") for i in [("w1", "clock-digital", "Digital Clock"), ("w2", "tasks", "Task Manager")] {
li.str("clock-digital") li.str(i.0)
li.str("Digital Clock") li.str(i.1)
li.str(i.2)
li.end_row() li.end_row()
}
publish(Instances, li) publish(Instances, li)
assert_true(p.on_event(false, PointerDown(1, 1))) assert_true(p.on_event(false, PointerDown(1, 1)))
assert_true(p.on_event(true, KeyDown("3"))) // the Panel tab 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") None => fail("popup should be open")
Some(ps) => { Some(ps) => {
let ts = texts_of(ps.ops) let ts = texts_of(ps.ops)
assert_true(ts.contains("Digital Clock"))
assert_true(ts.contains("Moon Phase (disc)")) 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. // Below the tab bar (40): heading (28), the two panel rows (30 each, buttons up at x 222-246,
ignore(p.on_event(true, PointerDown(20, 40 + 28 + 3))) // down 248-272, remove 284-308), heading (28), "Clocks" (22), two Add rows (42 each), Browse.
ignore(p.on_event(true, PointerDown(20, 40 + 3 * 28 + 3))) ignore(p.on_event(true, PointerDown(20, 82))) // w1's row itself: nothing
ignore(p.on_event(true, PointerDown(20, 40 + 4 * 28 + 3))) ignore(p.on_event(true, PointerDown(234, 82))) // w1 is first: up does nothing
assert_eq(drain(), [UnloadInstance("w1"), LoadModule("/m/moon-disc.wasm"), Browse]) 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() p.unload()
} }
+3
View File
@@ -253,6 +253,9 @@ impl chandra::host::plasmoids::Host for State {
Req::SetInspector(b) => R::SetInspector(b), Req::SetInspector(b) => R::SetInspector(b),
Req::LoadModule(s) => R::LoadModule(s), Req::LoadModule(s) => R::LoadModule(s),
Req::UnloadInstance(s) => R::UnloadInstance(s), Req::UnloadInstance(s) => R::UnloadInstance(s),
Req::MoveInstance(slot, delta) => {
R::MoveInstance(chandra::host::plasmoids::InstanceMove { slot, delta })
}
Req::Browse => R::Browse, Req::Browse => R::Browse,
Req::Logout => R::Logout, Req::Logout => R::Logout,
Req::SetWallpaper(n) => R::SetWallpaper(n), Req::SetWallpaper(n) => R::SetWallpaper(n),
+5
View File
@@ -42,6 +42,8 @@ pub enum Req {
SetInspector(bool), SetInspector(bool),
LoadModule(String), LoadModule(String),
UnloadInstance(String), UnloadInstance(String),
/// Move a panel instance `delta` places (negative: towards the start).
MoveInstance(String, i32),
Browse, Browse,
Logout, Logout,
SetWallpaper(i32), SetWallpaper(i32),
@@ -300,6 +302,9 @@ impl d::modules::Host for PState {
fn unload_instance(&mut self, slot: String) { fn unload_instance(&mut self, slot: String) {
self.shared.borrow_mut().requests.push_back(Req::UnloadInstance(slot)); self.shared.borrow_mut().requests.push_back(Req::UnloadInstance(slot));
} }
fn move_instance(&mut self, slot: String, delta: i32) {
self.shared.borrow_mut().requests.push_back(Req::MoveInstance(slot, delta));
}
fn browse(&mut self) { fn browse(&mut self) {
self.shared.borrow_mut().requests.push_back(Req::Browse); self.shared.borrow_mut().requests.push_back(Req::Browse);
} }
+15 -12
View File
@@ -12,20 +12,25 @@ fn wasmImportLoadModule(p0 : Int, p1 : Int) = "chandra:desktop/modules@0.1.0" "
///| ///|
fn wasmImportUnloadInstance(p0 : Int, p1 : Int) = "chandra:desktop/modules@0.1.0" "unload-instance" fn wasmImportUnloadInstance(p0 : Int, p1 : Int) = "chandra:desktop/modules@0.1.0" "unload-instance"
///|
fn wasmImportMoveInstance(p0 : Int, p1 : Int, p2 : Int) = "chandra:desktop/modules@0.1.0" "move-instance"
///| ///|
fn wasmImportBrowse() = "chandra:desktop/modules@0.1.0" "browse" fn wasmImportBrowse() = "chandra:desktop/modules@0.1.0" "browse"
///| ///|
extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int = extern "wasm" fn mbt_ffi_free(position : Int) =
#|(func (param i32) (result i32) (local i32) #|(func (param i32) local.get 0 call $moonbit.decref)
#| 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_load32(offset : Int) -> Int = extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
#|(func (param i32) (result i32) local.get 0 i32.load) #|(func (param i32) (result i32) local.get 0 i32.load)
///|
#owned(str)
extern "wasm" fn mbt_ffi_str2ptr(str : String) -> Int =
#|(func (param i32) (result i32) local.get 0)
///| ///|
extern "wasm" fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String = extern "wasm" fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String =
#|(func (param i32) (param i32) (result i32) #|(func (param i32) (param i32) (result i32)
@@ -34,11 +39,9 @@ extern "wasm" fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String =
#| local.get 0) #| local.get 0)
///| ///|
extern "wasm" fn mbt_ffi_free(position : Int) = extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
#|(func (param i32) local.get 0 call $moonbit.decref) #|(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
#owned(str) #| local.get 1)
extern "wasm" fn mbt_ffi_str2ptr(str : String) -> Int =
#|(func (param i32) (result i32) local.get 0)
@@ -74,6 +74,15 @@ pub fn unload_instance(slot : String) -> Unit {
wasmImportUnloadInstance(ptr, slot.length()); wasmImportUnloadInstance(ptr, slot.length());
mbt_ffi_free(ptr) mbt_ffi_free(ptr)
}
///|
/// Move one loaded instance `delta` places along the panel (negative: towards the start).
pub fn move_instance(slot : String, delta : Int) -> Unit {
let ptr = mbt_ffi_str2ptr(slot)
wasmImportMoveInstance(ptr, slot.length(), delta);
mbt_ffi_free(ptr)
} }
///| ///|
/// Ask the host to show its native file chooser for a .wasm elsewhere on disk. /// Ask the host to show its native file chooser for a .wasm elsewhere on disk.
@@ -61,6 +61,11 @@ pub(all) struct ConfigItem {
value : String value : String
} }
pub(all) struct InstanceMove {
slot : String
delta : Int32
}
pub(all) struct Loaded { pub(all) struct Loaded {
handle : UInt32 handle : UInt32
id : String id : String
@@ -104,6 +109,7 @@ pub(all) enum Request {
SetSuspendAfter(Int32) SetSuspendAfter(Int32)
PowerAction(Int32) PowerAction(Int32)
Network(NetworkRequest) Network(NetworkRequest)
MoveInstance(InstanceMove)
} }
pub(all) struct SettingChange { pub(all) struct SettingChange {
+14 -2
View File
@@ -30,6 +30,11 @@ pub(all) struct NetworkRequest {
action : Int; ssid : String; password : String action : Int; ssid : String; password : String
} }
///| ///|
/// A module moving a panel instance `delta` places (negative: towards the start).
pub(all) struct InstanceMove {
slot : String; delta : Int
}
///|
/// A module turning a session setting on or off. /// A module turning a session setting on or off.
pub(all) struct SettingChange { pub(all) struct SettingChange {
index : Int; on : Bool index : Int; on : Bool
@@ -52,6 +57,7 @@ pub(all) enum Request {
SetSuspendAfter(Int) SetSuspendAfter(Int)
PowerAction(Int) PowerAction(Int)
Network(NetworkRequest) Network(NetworkRequest)
MoveInstance(InstanceMove)
} }
///| ///|
/// A native file-chooser dialog (zenity on the host session) for "Add widget". /// A native file-chooser dialog (zenity on the host session) for "Add widget".
@@ -477,7 +483,7 @@ pub fn next_request() -> Request? {
let return_area = mbt_ffi_malloc(28) let return_area = mbt_ffi_malloc(28)
wasmImportNextRequest(return_area); wasmImportNextRequest(return_area);
let lifted4 : Request? = match mbt_ffi_load8_u((return_area) + 0) { let lifted5 : Request? = match mbt_ffi_load8_u((return_area) + 0) {
0 => Option::None 0 => Option::None
1 => { 1 => {
@@ -552,6 +558,12 @@ pub fn next_request() -> Request? {
Request::Network(NetworkRequest::{action : mbt_ffi_load32((return_area) + 8), ssid : result2, password : result3}) Request::Network(NetworkRequest::{action : mbt_ffi_load32((return_area) + 8), ssid : result2, password : result3})
} }
15 => {
let result4 = mbt_ffi_ptr2str(mbt_ffi_load32((return_area) + 8), mbt_ffi_load32((return_area) + 12))
Request::MoveInstance(InstanceMove::{slot : result4, delta : mbt_ffi_load32((return_area) + 16)})
}
_ => panic() _ => panic()
} }
@@ -559,7 +571,7 @@ pub fn next_request() -> Request? {
} }
_ => panic() _ => panic()
} }
let ret = lifted4 let ret = lifted5
mbt_ffi_free(return_area) mbt_ffi_free(return_area)
return ret return ret
+2
View File
@@ -240,6 +240,8 @@ fn request_val(r : @wasm.HostRequest) -> @wt.Val {
SetInspector(b) => Variant("set-inspector", Some(Bool(b))) SetInspector(b) => Variant("set-inspector", Some(Bool(b)))
LoadModule(s) => Variant("load-module", Some(Str(s))) LoadModule(s) => Variant("load-module", Some(Str(s)))
UnloadInstance(s) => Variant("unload-instance", Some(Str(s))) UnloadInstance(s) => Variant("unload-instance", Some(Str(s)))
MoveInstance(slot, delta) =>
Variant("move-instance", Some(Record([("slot", Str(slot)), ("delta", S32(delta))])))
Browse => Variant("browse", None) Browse => Variant("browse", None)
Logout => Variant("logout", None) Logout => Variant("logout", None)
SetWallpaper(n) => Variant("set-wallpaper", Some(S32(n))) SetWallpaper(n) => Variant("set-wallpaper", Some(S32(n)))
+2
View File
@@ -116,6 +116,8 @@ interface modules {
load-module: func(path: string); load-module: func(path: string);
/// Unload one loaded instance, freeing its panel space. /// Unload one loaded instance, freeing its panel space.
unload-instance: func(slot: string); unload-instance: func(slot: string);
/// Move one loaded instance `delta` places along the panel (negative: towards the start).
move-instance: func(slot: string, delta: s32);
/// Ask the host to show its native file chooser for a .wasm elsewhere on disk. /// Ask the host to show its native file chooser for a .wasm elsewhere on disk.
browse: func(); browse: func();
} }
+7
View File
@@ -101,6 +101,12 @@ interface plasmoids {
password: string, password: string,
} }
/// A module moving a panel instance `delta` places (negative: towards the start).
record instance-move {
slot: string,
delta: s32,
}
/// A module turning a session setting on or off. /// A module turning a session setting on or off.
record setting-change { record setting-change {
index: s32, index: s32,
@@ -129,6 +135,7 @@ interface plasmoids {
set-suspend-after(s32), set-suspend-after(s32),
power-action(s32), power-action(s32),
network(network-request), network(network-request),
move-instance(instance-move),
} }
/// The next pending request, oldest first. /// The next pending request, oldest first.
next-request: func() -> option<request>; next-request: func() -> option<request>;