Panel: add a Show Desktop module at the panel's end

- Clicking it hides every window, as Super+D does; it stays lit while the desktop is shown.
- A second click brings the hidden windows back.
- New show-desktop capability (wit toggle and publish-desktop-shown) for the wasm module.
- Added to the default panel after session settings; existing panels are unchanged.
- Test covers hiding, the lit state, and restoring the windows.
This commit is contained in:
nandi committed 2026-11-30 12:24:01 -08:00
1 parent 51852f0dac
commit 44bb77871d
31 files changed
+869 -49

No files matched your search

+2
View File
@@ -175,6 +175,8 @@ a recording shortcut again to stop.
* **Clocks**: the Digital Clock (12-hour with AM/PM by default, 24-hour in its Module settings) * **Clocks**: the Digital Clock (12-hour with AM/PM by default, 24-hour in its Module settings)
and a binary clock. and a binary clock.
* **Screenshot**, **Layout** (Tile | Float), **Inspector** (interface explorer). * **Screenshot**, **Layout** (Tile | Float), **Inspector** (interface explorer).
* **Show Desktop** (add it from Settings > Panel): hides every window, as Super+D does, and stays lit while
the desktop is shown; click it again to bring the windows back.
* **Settings**: tabs for Session (reopen windows at login, remember window positions, dark * **Settings**: tabs for Session (reopen windows at login, remember window positions, dark
mode), Desktop (what fills the desktop, wallpapers), Panel (add, remove and replace modules), Power (screen off and mode), Desktop (what fills the desktop, wallpapers), Panel (add, remove and replace modules), Power (screen off and
suspend when idle, battery, suspend / restart / power off), Shortcuts and Apps (the default web suspend when idle, battery, suspend / restart / power off), Shortcuts and Apps (the default web
+82
View File
@@ -0,0 +1,82 @@
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
///|
pub fn mbt_ffi_cabi_realloc(
src_offset : Int,
src_size : Int,
_dst_alignment : Int,
dst_size : Int,
) -> Int {
// malloc
if src_offset == 0 && src_size == 0 {
return mbt_ffi_malloc(dst_size)
}
// free
if dst_size == 0 {
mbt_ffi_free(src_offset)
return 0
}
// realloc
let dst = mbt_ffi_malloc(dst_size)
mbt_ffi_copy(dst, src_offset, if src_size < dst_size { src_size } else { dst_size })
mbt_ffi_free(src_offset)
dst
}
///|
extern "wasm" fn mbt_ffi_copy(dest : Int, src : Int, len : Int) =
#|(func (param i32) (param i32) (param i32) local.get 0 local.get 1 local.get 2 memory.copy)
///|
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)
///|
#doc(hidden)
pub fn wasmExportInfo() -> Int {
@plasmoid.wasmExportInfo()
}
///|
#doc(hidden)
pub fn wasmExportRender(p0 : Int, p1 : Int) -> Int {
@plasmoid.wasmExportRender(p0, p1)
}
///|
#doc(hidden)
pub fn wasmExportRenderPostReturn(p0 : Int) -> Unit {
@plasmoid.wasmExportRenderPostReturn(p0)
}
///|
#doc(hidden)
pub fn wasmExportPopup() -> Int {
@plasmoid.wasmExportPopup()
}
///|
#doc(hidden)
pub fn wasmExportOnEvent(p0 : Int, p1 : Int, p2 : Int, p3 : Int) -> Int {
@plasmoid.wasmExportOnEvent(p0, p1, p2, p3)
}
///|
#doc(hidden)
pub fn wasmExportPopupPostReturn(p0 : Int) -> Unit {
@plasmoid.wasmExportPopupPostReturn(p0)
}
///|
#doc(hidden)
pub fn wasmExportInfoPostReturn(p0 : Int) -> Unit {
@plasmoid.wasmExportInfoPostReturn(p0)
}
@@ -0,0 +1 @@
The widget (plasmoid) contract.
@@ -0,0 +1,431 @@
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
///|
#doc(hidden)
pub fn wasmExportInfo() -> Int {
let (result) : (PlasmoidInfo) = info();
let return_area = mbt_ffi_malloc(32)
let ptr = mbt_ffi_str2ptr((result).id)
mbt_ffi_store32((return_area) + 4, (result).id.length())
mbt_ffi_store32((return_area) + 0, ptr)
let ptr0 = mbt_ffi_str2ptr((result).name)
mbt_ffi_store32((return_area) + 12, (result).name.length())
mbt_ffi_store32((return_area) + 8, ptr0)
mbt_ffi_store32((return_area) + 16, (((result).preferred).w).reinterpret_as_int())
mbt_ffi_store32((return_area) + 20, (((result).preferred).h).reinterpret_as_int())
mbt_ffi_store32((return_area) + 24, ((result).min_width).reinterpret_as_int())
mbt_ffi_store8((return_area) + 28, (if (result).stretch { 1 } else { 0 }))
let ret = return_area
return ret
}
///|
#doc(hidden)
pub fn wasmExportInfoPostReturn(p0 : Int) -> Unit {
mbt_ffi_free(mbt_ffi_load32((p0) + 0))
mbt_ffi_free(mbt_ffi_load32((p0) + 8))
}
///|
#doc(hidden)
pub fn wasmExportRender(p0 : Int, p1 : Int) -> Int {
let (result) : (Array[@types.DrawOp]) = render(@types.Size::{w : (p0).reinterpret_as_uint(), h : (p1).reinterpret_as_uint()});
let return_area = mbt_ffi_malloc(8)
let address = mbt_ffi_malloc((result).length() * 32);
for index = 0; index < (result).length(); index = index + 1 {
let iter_elem : @types.DrawOp = (result)[(index)]
let iter_base = address + (index * 32);
match iter_elem {
FillRect(payload) => {
mbt_ffi_store8((iter_base) + 0, (0))
mbt_ffi_store32((iter_base) + 4, ((payload).rect).x)
mbt_ffi_store32((iter_base) + 8, ((payload).rect).y)
mbt_ffi_store32((iter_base) + 12, (((payload).rect).w).reinterpret_as_int())
mbt_ffi_store32((iter_base) + 16, (((payload).rect).h).reinterpret_as_int())
mbt_ffi_store8((iter_base) + 20, (((payload).color).r).to_int())
mbt_ffi_store8((iter_base) + 21, (((payload).color).g).to_int())
mbt_ffi_store8((iter_base) + 22, (((payload).color).b).to_int())
mbt_ffi_store8((iter_base) + 23, (((payload).color).a).to_int())
mbt_ffi_store32((iter_base) + 24, ((payload).radius).reinterpret_as_int())
()
}
StrokeRect(payload0) => {
mbt_ffi_store8((iter_base) + 0, (1))
mbt_ffi_store32((iter_base) + 4, ((payload0).rect).x)
mbt_ffi_store32((iter_base) + 8, ((payload0).rect).y)
mbt_ffi_store32((iter_base) + 12, (((payload0).rect).w).reinterpret_as_int())
mbt_ffi_store32((iter_base) + 16, (((payload0).rect).h).reinterpret_as_int())
mbt_ffi_store8((iter_base) + 20, (((payload0).color).r).to_int())
mbt_ffi_store8((iter_base) + 21, (((payload0).color).g).to_int())
mbt_ffi_store8((iter_base) + 22, (((payload0).color).b).to_int())
mbt_ffi_store8((iter_base) + 23, (((payload0).color).a).to_int())
mbt_ffi_store32((iter_base) + 24, ((payload0).width).reinterpret_as_int())
mbt_ffi_store32((iter_base) + 28, ((payload0).radius).reinterpret_as_int())
()
}
Line(payload1) => {
mbt_ffi_store8((iter_base) + 0, (2))
mbt_ffi_store32((iter_base) + 4, ((payload1).start).x)
mbt_ffi_store32((iter_base) + 8, ((payload1).start).y)
mbt_ffi_store32((iter_base) + 12, ((payload1).end).x)
mbt_ffi_store32((iter_base) + 16, ((payload1).end).y)
mbt_ffi_store8((iter_base) + 20, (((payload1).color).r).to_int())
mbt_ffi_store8((iter_base) + 21, (((payload1).color).g).to_int())
mbt_ffi_store8((iter_base) + 22, (((payload1).color).b).to_int())
mbt_ffi_store8((iter_base) + 23, (((payload1).color).a).to_int())
mbt_ffi_store32((iter_base) + 24, ((payload1).width).reinterpret_as_int())
()
}
Circle(payload2) => {
mbt_ffi_store8((iter_base) + 0, (3))
mbt_ffi_store32((iter_base) + 4, ((payload2).center).x)
mbt_ffi_store32((iter_base) + 8, ((payload2).center).y)
mbt_ffi_store32((iter_base) + 12, ((payload2).radius).reinterpret_as_int())
mbt_ffi_store8((iter_base) + 16, (((payload2).color).r).to_int())
mbt_ffi_store8((iter_base) + 17, (((payload2).color).g).to_int())
mbt_ffi_store8((iter_base) + 18, (((payload2).color).b).to_int())
mbt_ffi_store8((iter_base) + 19, (((payload2).color).a).to_int())
mbt_ffi_store8((iter_base) + 20, (if (payload2).filled { 1 } else { 0 }))
()
}
Text(payload3) => {
mbt_ffi_store8((iter_base) + 0, (4))
mbt_ffi_store32((iter_base) + 4, ((payload3).origin).x)
mbt_ffi_store32((iter_base) + 8, ((payload3).origin).y)
let ptr = mbt_ffi_str2ptr((payload3).text)
mbt_ffi_store32((iter_base) + 16, (payload3).text.length())
mbt_ffi_store32((iter_base) + 12, ptr)
mbt_ffi_store32((iter_base) + 20, (((payload3).style).size).reinterpret_as_int())
mbt_ffi_store8((iter_base) + 24, ((((payload3).style).color).r).to_int())
mbt_ffi_store8((iter_base) + 25, ((((payload3).style).color).g).to_int())
mbt_ffi_store8((iter_base) + 26, ((((payload3).style).color).b).to_int())
mbt_ffi_store8((iter_base) + 27, ((((payload3).style).color).a).to_int())
mbt_ffi_store8((iter_base) + 28, ((payload3).style).align.ordinal())
mbt_ffi_store8((iter_base) + 29, (if ((payload3).style).bold { 1 } else { 0 }))
()
}
PushClip(payload4) => {
mbt_ffi_store8((iter_base) + 0, (5))
mbt_ffi_store32((iter_base) + 4, (payload4).x)
mbt_ffi_store32((iter_base) + 8, (payload4).y)
mbt_ffi_store32((iter_base) + 12, ((payload4).w).reinterpret_as_int())
mbt_ffi_store32((iter_base) + 16, ((payload4).h).reinterpret_as_int())
()
}
PopClip => {
mbt_ffi_store8((iter_base) + 0, (6))
()
}
Image(payload6) => {
mbt_ffi_store8((iter_base) + 0, (7))
mbt_ffi_store32((iter_base) + 4, ((payload6).rect).x)
mbt_ffi_store32((iter_base) + 8, ((payload6).rect).y)
mbt_ffi_store32((iter_base) + 12, (((payload6).rect).w).reinterpret_as_int())
mbt_ffi_store32((iter_base) + 16, (((payload6).rect).h).reinterpret_as_int())
mbt_ffi_store32((iter_base) + 20, ((payload6).image).reinterpret_as_int())
()
}
}
}
mbt_ffi_store32((return_area) + 4, (result).length())
mbt_ffi_store32((return_area) + 0, address)
let ret = return_area
return ret
}
///|
#doc(hidden)
pub fn wasmExportRenderPostReturn(p0 : Int) -> Unit {
for index = 0; index < (mbt_ffi_load32((p0) + 4)); index = index + 1 {
let iter_base = (mbt_ffi_load32((p0) + 0)) + (index * 32)
match (mbt_ffi_load8_u((iter_base) + 0)) {
0 => ()
1 => ()
2 => ()
3 => ()
4 => {
mbt_ffi_free(mbt_ffi_load32((iter_base) + 12))
}
5 => ()
6 => ()
7 => ()
_ => panic()
}
}
mbt_ffi_free(mbt_ffi_load32((p0) + 0))
}
///|
#doc(hidden)
pub fn wasmExportPopup() -> Int {
let (result) : (PopupSurface?) = popup();
let return_area = mbt_ffi_malloc(20)
match (result) {
None => {
mbt_ffi_store8((return_area) + 0, (0))
()
}
Some(payload0) => {
mbt_ffi_store8((return_area) + 0, (1))
mbt_ffi_store32((return_area) + 4, (((payload0).size).w).reinterpret_as_int())
mbt_ffi_store32((return_area) + 8, (((payload0).size).h).reinterpret_as_int())
let address = mbt_ffi_malloc(((payload0).ops).length() * 32);
for index = 0; index < ((payload0).ops).length(); index = index + 1 {
let iter_elem : @types.DrawOp = ((payload0).ops)[(index)]
let iter_base = address + (index * 32);
match iter_elem {
FillRect(payload1) => {
mbt_ffi_store8((iter_base) + 0, (0))
mbt_ffi_store32((iter_base) + 4, ((payload1).rect).x)
mbt_ffi_store32((iter_base) + 8, ((payload1).rect).y)
mbt_ffi_store32((iter_base) + 12, (((payload1).rect).w).reinterpret_as_int())
mbt_ffi_store32((iter_base) + 16, (((payload1).rect).h).reinterpret_as_int())
mbt_ffi_store8((iter_base) + 20, (((payload1).color).r).to_int())
mbt_ffi_store8((iter_base) + 21, (((payload1).color).g).to_int())
mbt_ffi_store8((iter_base) + 22, (((payload1).color).b).to_int())
mbt_ffi_store8((iter_base) + 23, (((payload1).color).a).to_int())
mbt_ffi_store32((iter_base) + 24, ((payload1).radius).reinterpret_as_int())
()
}
StrokeRect(payload2) => {
mbt_ffi_store8((iter_base) + 0, (1))
mbt_ffi_store32((iter_base) + 4, ((payload2).rect).x)
mbt_ffi_store32((iter_base) + 8, ((payload2).rect).y)
mbt_ffi_store32((iter_base) + 12, (((payload2).rect).w).reinterpret_as_int())
mbt_ffi_store32((iter_base) + 16, (((payload2).rect).h).reinterpret_as_int())
mbt_ffi_store8((iter_base) + 20, (((payload2).color).r).to_int())
mbt_ffi_store8((iter_base) + 21, (((payload2).color).g).to_int())
mbt_ffi_store8((iter_base) + 22, (((payload2).color).b).to_int())
mbt_ffi_store8((iter_base) + 23, (((payload2).color).a).to_int())
mbt_ffi_store32((iter_base) + 24, ((payload2).width).reinterpret_as_int())
mbt_ffi_store32((iter_base) + 28, ((payload2).radius).reinterpret_as_int())
()
}
Line(payload3) => {
mbt_ffi_store8((iter_base) + 0, (2))
mbt_ffi_store32((iter_base) + 4, ((payload3).start).x)
mbt_ffi_store32((iter_base) + 8, ((payload3).start).y)
mbt_ffi_store32((iter_base) + 12, ((payload3).end).x)
mbt_ffi_store32((iter_base) + 16, ((payload3).end).y)
mbt_ffi_store8((iter_base) + 20, (((payload3).color).r).to_int())
mbt_ffi_store8((iter_base) + 21, (((payload3).color).g).to_int())
mbt_ffi_store8((iter_base) + 22, (((payload3).color).b).to_int())
mbt_ffi_store8((iter_base) + 23, (((payload3).color).a).to_int())
mbt_ffi_store32((iter_base) + 24, ((payload3).width).reinterpret_as_int())
()
}
Circle(payload4) => {
mbt_ffi_store8((iter_base) + 0, (3))
mbt_ffi_store32((iter_base) + 4, ((payload4).center).x)
mbt_ffi_store32((iter_base) + 8, ((payload4).center).y)
mbt_ffi_store32((iter_base) + 12, ((payload4).radius).reinterpret_as_int())
mbt_ffi_store8((iter_base) + 16, (((payload4).color).r).to_int())
mbt_ffi_store8((iter_base) + 17, (((payload4).color).g).to_int())
mbt_ffi_store8((iter_base) + 18, (((payload4).color).b).to_int())
mbt_ffi_store8((iter_base) + 19, (((payload4).color).a).to_int())
mbt_ffi_store8((iter_base) + 20, (if (payload4).filled { 1 } else { 0 }))
()
}
Text(payload5) => {
mbt_ffi_store8((iter_base) + 0, (4))
mbt_ffi_store32((iter_base) + 4, ((payload5).origin).x)
mbt_ffi_store32((iter_base) + 8, ((payload5).origin).y)
let ptr = mbt_ffi_str2ptr((payload5).text)
mbt_ffi_store32((iter_base) + 16, (payload5).text.length())
mbt_ffi_store32((iter_base) + 12, ptr)
mbt_ffi_store32((iter_base) + 20, (((payload5).style).size).reinterpret_as_int())
mbt_ffi_store8((iter_base) + 24, ((((payload5).style).color).r).to_int())
mbt_ffi_store8((iter_base) + 25, ((((payload5).style).color).g).to_int())
mbt_ffi_store8((iter_base) + 26, ((((payload5).style).color).b).to_int())
mbt_ffi_store8((iter_base) + 27, ((((payload5).style).color).a).to_int())
mbt_ffi_store8((iter_base) + 28, ((payload5).style).align.ordinal())
mbt_ffi_store8((iter_base) + 29, (if ((payload5).style).bold { 1 } else { 0 }))
()
}
PushClip(payload6) => {
mbt_ffi_store8((iter_base) + 0, (5))
mbt_ffi_store32((iter_base) + 4, (payload6).x)
mbt_ffi_store32((iter_base) + 8, (payload6).y)
mbt_ffi_store32((iter_base) + 12, ((payload6).w).reinterpret_as_int())
mbt_ffi_store32((iter_base) + 16, ((payload6).h).reinterpret_as_int())
()
}
PopClip => {
mbt_ffi_store8((iter_base) + 0, (6))
()
}
Image(payload8) => {
mbt_ffi_store8((iter_base) + 0, (7))
mbt_ffi_store32((iter_base) + 4, ((payload8).rect).x)
mbt_ffi_store32((iter_base) + 8, ((payload8).rect).y)
mbt_ffi_store32((iter_base) + 12, (((payload8).rect).w).reinterpret_as_int())
mbt_ffi_store32((iter_base) + 16, (((payload8).rect).h).reinterpret_as_int())
mbt_ffi_store32((iter_base) + 20, ((payload8).image).reinterpret_as_int())
()
}
}
}
mbt_ffi_store32((return_area) + 16, ((payload0).ops).length())
mbt_ffi_store32((return_area) + 12, address)
()
}
}
let ret = return_area
return ret
}
///|
#doc(hidden)
pub fn wasmExportPopupPostReturn(p0 : Int) -> Unit {
match (mbt_ffi_load8_u((p0) + 0)) {
0 => ()
1 => {
for index = 0; index < (mbt_ffi_load32((p0) + 16)); index = index + 1 {
let iter_base = (mbt_ffi_load32((p0) + 12)) + (index * 32)
match (mbt_ffi_load8_u((iter_base) + 0)) {
0 => ()
1 => ()
2 => ()
3 => ()
4 => {
mbt_ffi_free(mbt_ffi_load32((iter_base) + 12))
}
5 => ()
6 => ()
7 => ()
_ => panic()
}
}
mbt_ffi_free(mbt_ffi_load32((p0) + 12))
}
_ => panic()
}
}
///|
#doc(hidden)
pub fn wasmExportOnEvent(p0 : Int, p1 : Int, p2 : Int, p3 : Int) -> Int {
let lifted = match (p1) {
0 => {
@types.InputEvent::PointerMove(@types.Point::{x : p2, y : p3})
}
1 => {
@types.InputEvent::PointerDown(@types.Point::{x : p2, y : p3})
}
2 => {
@types.InputEvent::PointerUp(@types.Point::{x : p2, y : p3})
}
3 => {
@types.InputEvent::PointerLeave
}
4 => {
@types.InputEvent::FocusLost
}
5 => {
let result = mbt_ffi_ptr2str(p2, p3)
@types.InputEvent::KeyDown(result)
}
_ => panic()
}
let (result0) : (Bool) = on_event(Surface::from(p0), lifted);
let ret = (if result0 { 1 } else { 0 })
return ret
}
///|
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_load32(offset : Int) -> Int =
#|(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_store32(offset : Int, value : Int) =
#|(func (param i32) (param i32) local.get 0 local.get 1 i32.store)
///|
extern "wasm" fn mbt_ffi_free(position : Int) =
#|(func (param i32) local.get 0 call $moonbit.decref)
///|
extern "wasm" fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String =
#|(func (param i32) (param i32) (result i32)
#| local.get 0
#| local.get 1 call $moonbit.init_array16
#| local.get 0)
///|
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_store8(offset : Int, value : Int) =
#|(func (param i32) (param i32) local.get 0 local.get 1 i32.store8)
@@ -0,0 +1,8 @@
import {
"chandra/desktop/interface/chandra/desktop/types" @types,
"chandra/desktop/interface/chandra/desktop/theme" @theme,
"chandra/desktop/interface/chandra/desktop/show-desktop" @desk,
"chandra/desktop/lib/ui" @ui,
}
warnings = "-44"
@@ -0,0 +1,76 @@
///| Implementation of `chandra:desktop/plasmoid` for Show Desktop, after KDE's: a panel button
/// that hides every window of the active workspace (as Super+D does) and, clicked again while
/// nothing is on screen, brings them back. It stays lit while the desktop is shown.
///| The pointer is over the button.
let hovered : Ref[Bool] = { val: false }
///|
pub fn info() -> PlasmoidInfo {
{
id: "org.chandra.show-desktop",
name: "Show Desktop",
preferred: { w: 34, h: 34 },
min_width: 34,
stretch: false,
}
}
///| A monitor on its stand; with a window on it unless the desktop is shown.
fn monitor(cx : Int, cy : Int, c : @types.Color, empty : Bool) -> Array[@types.DrawOp] {
let ops = [
@ui.stroke_rect(@ui.rect(cx - 10, cy - 8, 20, 14), c, width=1, radius=2),
@ui.line(cx, cy + 6, cx, cy + 9, c),
@ui.line(cx - 5, cy + 9, cx + 5, cy + 9, c),
]
if !empty {
ops.push(@ui.fill_rect(@ui.rect(cx - 6, cy - 5, 10, 7), c, radius=1))
}
ops
}
///|
pub fn render(size : @types.Size) -> Array[@types.DrawOp] {
let t = @theme.get_tokens()
let w = size.w.reinterpret_as_int()
let h = size.h.reinterpret_as_int()
let shown = @desk.is_shown()
let bg = if shown { t.palette.accent } else { t.palette.surface_hover }
let fg = if shown { t.palette.accent_foreground } else { t.palette.foreground }
let ops : Array[@types.DrawOp] = []
if shown || hovered.val {
ops.push(@ui.fill_rect(@ui.rect(0, 0, w, h), bg, radius=t.radius.reinterpret_as_int()))
}
ops.append(monitor(w / 2, h / 2 - 1, fg, shown))
ops
}
///|
pub fn popup() -> PopupSurface? {
None
}
///|
pub fn on_event(target : Surface, event : @types.InputEvent) -> Bool {
match (target, event) {
(WIDGET, PointerDown(_)) => {
@desk.toggle()
true
}
(WIDGET, PointerMove(_)) =>
if hovered.val {
false
} else {
hovered.val = true
true
}
(WIDGET, PointerLeave) =>
if hovered.val {
hovered.val = false
true
} else {
false
}
_ => false
}
}
@@ -0,0 +1,42 @@
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
///|
pub(all) struct PlasmoidInfo {
id : String; name : String; preferred : @types.Size; min_width : UInt; stretch : Bool
}
///|
pub(all) struct PopupSurface {
size : @types.Size; ops : Array[@types.DrawOp]
}
///|
pub(all) enum Surface {
WIDGET; POPUP
} derive()
///|
pub fn Surface::ordinal(self : Surface) -> Int {
match self {
WIDGET => 0
POPUP => 1
}
}
///|
pub fn Surface::from(self : Int) -> Surface {
match self {
0 => WIDGET
1 => POPUP
_ => panic()
}
}
///|
declare pub fn info() -> PlasmoidInfo
///|
/// Draw the widget into a `size` box (local coordinates).
declare pub fn render(size : @types.Size) -> Array[@types.DrawOp]
///|
/// Present when the widget wants a popup surface (e.g. a launcher menu).
declare pub fn popup() -> PopupSurface?
///|
/// Returns true when the widget's visuals changed and a redraw is needed.
declare pub fn on_event(target : Surface, event : @types.InputEvent) -> Bool
+26
View File
@@ -0,0 +1,26 @@
import {
"chandra/desktop/components/show-desktop/gen/interface/chandra/desktop/plasmoid" @plasmoid,
}
warnings = "-44"
pkgtype(kind: "foreign_library")
options(
link: {
"wasm": {
"export-memory-name": "memory",
"heap-start-address": 16,
"exports": [
"mbt_ffi_cabi_realloc:cabi_realloc",
"wasmExportInfo:chandra:desktop/plasmoid@0.1.0#info",
"wasmExportInfoPostReturn:cabi_post_chandra:desktop/plasmoid@0.1.0#info",
"wasmExportOnEvent:chandra:desktop/plasmoid@0.1.0#on-event",
"wasmExportPopup:chandra:desktop/plasmoid@0.1.0#popup",
"wasmExportPopupPostReturn:cabi_post_chandra:desktop/plasmoid@0.1.0#popup",
"wasmExportRender:chandra:desktop/plasmoid@0.1.0#render",
"wasmExportRenderPostReturn:cabi_post_chandra:desktop/plasmoid@0.1.0#render"
],
},
},
)
+2
View File
@@ -1336,6 +1336,7 @@ fn ChandraCompositor::build_scene(
(if self.rec_pointer { 2 } else { 0 }) (if self.rec_pointer { 2 } else { 0 })
self.shell.osk_visible = self.osk_visible self.shell.osk_visible = self.osk_visible
self.shell.rotation = self.pending_rotation.unwrap_or(self.rotation) self.shell.rotation = self.pending_rotation.unwrap_or(self.rotation)
self.shell.desktop_shown = self.desktop_shown()
// A window over the whole desktop (maximized, fullscreen, monocle) pauses a desktop module's // A window over the whole desktop (maximized, fullscreen, monocle) pauses a desktop module's
// animation: nobody can see it. // animation: nobody can see it.
self.shell.set_desktop_covered(self.desktop_covered()) self.shell.set_desktop_covered(self.desktop_covered())
@@ -2025,6 +2026,7 @@ fn ChandraCompositor::run_shell_actions(self : ChandraCompositor) -> Unit {
} }
@shell.ShellAction::SetOskVisible(v) => self.osk_set_manual_visible(v) @shell.ShellAction::SetOskVisible(v) => self.osk_set_manual_visible(v)
@shell.ShellAction::SetRotation(r) => self.request_rotation(r) @shell.ShellAction::SetRotation(r) => self.request_rotation(r)
@shell.ShellAction::ToggleDesktop => self.toggle_show_desktop()
@shell.ShellAction::SetLayout(m) => @shell.ShellAction::SetLayout(m) =>
match m { match m {
0 => self.set_layout_mode(@wm.LayoutMode::Tiling) 0 => self.set_layout_mode(@wm.LayoutMode::Tiling)
+35
View File
@@ -1460,6 +1460,41 @@ test "super+d minimizes every window to show the desktop, and again brings them
assert_false(comp.wm.windows.get(2UL).unwrap().minimized) assert_false(comp.wm.windows.get(2UL).unwrap().minimized)
} }
///|
test "the show desktop module hides the windows, lights up, and a second click brings them back" {
let socket_path = "/tmp/wayland-moon-showdesk-" + @sys.getpid().to_string() + ".sock"
let theme = @scene.ThemeTokens::moon_night()
let comp = @host.ChandraCompositor::new(socket_path, theme, 1280, 720).unwrap()
assert_true(comp.shell.load_module("show-desktop"))
ignore(comp.compose_frame())
ignore(open_and_configure_client(comp, socket_path, "A", "a"))
ignore(open_and_configure_client(comp, socket_path, "B", "b"))
ignore(comp.compose_frame())
// Lit (the accent behind the icon) only while the desktop is shown.
let lit = fn() {
match comp.shell.slot_ops(comp.shell.slot_of("show-desktop")) {
[FillRect(f), ..] => {
let a = comp.shell.tokens.palette.accent
f.color.r == a.r && f.color.g == a.g && f.color.b == a.b
}
_ => false
}
}
assert_false(lit())
click_module(comp, "show-desktop", 1U)
assert_true(comp.wm.windows.get(1UL).unwrap().minimized)
assert_true(comp.wm.windows.get(2UL).unwrap().minimized)
assert_true(comp.desktop_shown())
ignore(comp.compose_frame())
assert_true(lit())
click_module(comp, "show-desktop", 10U)
assert_false(comp.wm.windows.get(1UL).unwrap().minimized)
assert_false(comp.wm.windows.get(2UL).unwrap().minimized)
assert_false(comp.desktop_shown())
ignore(comp.compose_frame())
assert_false(lit())
}
///| Click (x, y) without drawing, then return the next scene's wallpaper op count (0: no new scene). ///| Click (x, y) without drawing, then return the next scene's wallpaper op count (0: no new scene).
fn click_wallpaper_ops(comp : @host.ChandraCompositor, x : Int, y : Int, t : UInt) -> Int { fn click_wallpaper_ops(comp : @host.ChandraCompositor, x : Int, y : Int, t : UInt) -> Int {
comp.handle_input(@nested.InputEvent::PointerMove(x.to_double(), y.to_double()), t) comp.handle_input(@nested.InputEvent::PointerMove(x.to_double(), y.to_double()), t)
+6
View File
@@ -172,6 +172,8 @@ pub(all) enum ShellAction {
SetOskVisible(Bool) SetOskVisible(Bool)
/// The Rotate panel module asked to set display rotation (0..3). /// The Rotate panel module asked to set display rotation (0..3).
SetRotation(Int) SetRotation(Int)
/// The Show Desktop module was clicked: hide the windows, or bring them back (as Super+D).
ToggleDesktop
} derive(Eq, Debug) } derive(Eq, Debug)
///| One wasm module loaded into the panel. ///| One wasm module loaded into the panel.
@@ -289,6 +291,9 @@ pub(all) struct DesktopShell {
mut osk_visible : Bool mut osk_visible : Bool
/// Current display rotation 0..3 (published to `rotation`). /// Current display rotation 0..3 (published to `rotation`).
mut rotation : Int mut rotation : Int
/// What the Show Desktop module is told (the compositor sets it every frame): the windows are
/// hidden and another toggle would bring them back.
mut desktop_shown : Bool
/// The network service (network.mbt), while a module imports `network`. /// The network service (network.mbt), while a module imports `network`.
mut net : @network.NetService? mut net : @network.NetService?
mut remember_windows : Bool mut remember_windows : Bool
@@ -468,6 +473,7 @@ pub fn DesktopShell::new(display : String) -> DesktopShell {
screenshot_state: 2, screenshot_state: 2,
osk_visible: false, osk_visible: false,
rotation: 0, rotation: 0,
desktop_shown: false,
net: None, net: None,
remember_windows: true, remember_windows: true,
native_auth_agent: true, native_auth_agent: true,
+4
View File
@@ -855,6 +855,9 @@ fn DesktopShell::publish_host_data(self : DesktopShell) -> Unit {
if self.any_cap("rotation") { if self.any_cap("rotation") {
@wasm.publish_rotation(self.rotation) @wasm.publish_rotation(self.rotation)
} }
if self.any_cap("show-desktop") {
@wasm.publish_desktop_shown(self.desktop_shown)
}
if self.any_cap("battery") { if self.any_cap("battery") {
let b = self.battery.refresh() let b = self.battery.refresh()
@wasm.publish_battery(b.percent, b.state, b.secs_left) @wasm.publish_battery(b.percent, b.state, b.secs_left)
@@ -1033,6 +1036,7 @@ fn DesktopShell::process_requests(self : DesktopShell) -> Unit {
Some(GameLibrary(code, game, mode)) => self.gamelib.request(code, game, mode) Some(GameLibrary(code, game, mode)) => self.gamelib.request(code, game, mode)
Some(SetOskVisible(v)) => self.actions.push(SetOskVisible(v)) Some(SetOskVisible(v)) => self.actions.push(SetOskVisible(v))
Some(SetRotation(r)) => self.actions.push(SetRotation(r)) Some(SetRotation(r)) => self.actions.push(SetRotation(r))
Some(ToggleDesktop) => self.actions.push(ToggleDesktop)
Some(PowerAction(a)) => if a >= 0 && a <= 2 { self.actions.push(SystemPower(a)) } Some(PowerAction(a)) => if a >= 0 && a <= 2 { self.actions.push(SystemPower(a)) }
Some(Network(code, ssid, password)) => self.network_request(code, ssid, password) Some(Network(code, ssid, password)) => self.network_request(code, ssid, password)
Some(SetInspector(on)) => self.set_inspecting(on) Some(SetInspector(on)) => self.set_inspecting(on)
+8
View File
@@ -427,6 +427,11 @@ pub fn publish_rotation(rot : Int) -> Unit {
@hostpl.publish_rotation(rot.reinterpret_as_uint()) @hostpl.publish_rotation(rot.reinterpret_as_uint())
} }
///| Publish whether show-desktop has the windows hidden.
pub fn publish_desktop_shown(shown : Bool) -> Unit {
@hostpl.publish_desktop_shown(shown)
}
///| The power timeouts, in minutes (0: never). ///| The power timeouts, in minutes (0: never).
pub fn publish_power(screen_off : Int, suspend : Int) -> Unit { pub fn publish_power(screen_off : Int, suspend : Int) -> Unit {
@hostpl.publish_power(screen_off.reinterpret_as_uint(), suspend.reinterpret_as_uint()) @hostpl.publish_power(screen_off.reinterpret_as_uint(), suspend.reinterpret_as_uint())
@@ -487,6 +492,8 @@ pub(all) enum HostRequest {
SetOskVisible(Bool) SetOskVisible(Bool)
/// The rotation capability: set display orientation (0..3). /// The rotation capability: set display orientation (0..3).
SetRotation(Int) SetRotation(Int)
/// The show-desktop capability's `toggle`: hide the windows, or bring back the ones it hid.
ToggleDesktop
} derive(Eq, Debug) } derive(Eq, Debug)
///| ///|
@@ -518,6 +525,7 @@ pub fn next_request() -> HostRequest? {
Some(GameLibrary(r)) => Some(GameLibrary(r.action, r.game, r.mode)) Some(GameLibrary(r)) => Some(GameLibrary(r.action, r.game, r.mode))
Some(SetOskVisible(v)) => Some(SetOskVisible(v)) Some(SetOskVisible(v)) => Some(SetOskVisible(v))
Some(SetRotation(r)) => Some(SetRotation(r)) Some(SetRotation(r)) => Some(SetRotation(r))
Some(ToggleDesktop) => Some(ToggleDesktop)
} }
} }
+8
View File
@@ -841,6 +841,11 @@ pub fn publish_rotation(rot : Int) -> Unit {
c_host_set_int(12, rot) c_host_set_int(12, rot)
} }
///| Publish whether show-desktop has the windows hidden.
pub fn publish_desktop_shown(shown : Bool) -> Unit {
c_host_set_int(13, if shown { 1 } else { 0 })
}
///| Publish the power timeouts, in minutes (0: never). ///| Publish the power timeouts, in minutes (0: never).
pub fn publish_power(screen_off : Int, suspend : Int) -> Unit { pub fn publish_power(screen_off : Int, suspend : Int) -> Unit {
c_host_set_int(5, screen_off) c_host_set_int(5, screen_off)
@@ -905,6 +910,8 @@ pub(all) enum HostRequest {
SetOskVisible(Bool) SetOskVisible(Bool)
/// The rotation capability: set display orientation (0..3). /// The rotation capability: set display orientation (0..3).
SetRotation(Int) SetRotation(Int)
/// The show-desktop capability's `toggle`: hide the windows, or bring back the ones it hid.
ToggleDesktop
} derive(Eq, Debug) } derive(Eq, Debug)
///| ///|
@@ -949,6 +956,7 @@ pub fn next_request() -> HostRequest? {
20 => Some(SetBrightness(c_host_req_int())) 20 => Some(SetBrightness(c_host_req_int()))
21 => Some(SetOskVisible(c_host_req_int() != 0)) 21 => Some(SetOskVisible(c_host_req_int() != 0))
22 => Some(SetRotation(c_host_req_int())) 22 => Some(SetRotation(c_host_req_int()))
23 => Some(ToggleDesktop)
40 => Some(SetDesktop(c_host_req_int())) 40 => Some(SetDesktop(c_host_req_int()))
44 => Some(FaceUnlock(c_host_req_int())) 44 => Some(FaceUnlock(c_host_req_int()))
45 => { 45 => {
+9 -2
View File
@@ -69,7 +69,8 @@ enum {
K_DESKTOPS, K_DESKTOP_CUR, K_SET_DESKTOP, K_DESKTOPS, K_DESKTOP_CUR, K_SET_DESKTOP,
K_FU_STATUS, K_FU_FACES, K_FU_ENROLL, K_FU_REMOVE, K_FU_SET_IN_USE, K_FU_REFRESH, K_FU_STATUS, K_FU_FACES, K_FU_ENROLL, K_FU_REMOVE, K_FU_SET_IN_USE, K_FU_REFRESH,
K_GL_STATUS, K_GL_GAMES, K_GL_MODES, K_GL_LAUNCH, K_GL_STOP, K_GL_FOCUS, K_GL_REFRESH, K_GL_STATUS, K_GL_GAMES, K_GL_MODES, K_GL_LAUNCH, K_GL_STOP, K_GL_FOCUS, K_GL_REFRESH,
K_OSK_IS_VISIBLE, K_OSK_SET_VISIBLE, K_ROT_CURRENT, K_ROT_SET K_OSK_IS_VISIBLE, K_OSK_SET_VISIBLE, K_ROT_CURRENT, K_ROT_SET,
K_DESK_SHOWN, K_DESK_TOGGLE
}; };
typedef struct Env { Inst *inst; int kind; } Env; typedef struct Env { Inst *inst; int kind; } Env;
@@ -87,7 +88,7 @@ static int32_t host_ints[24] = {[7] = -1, [10] = -1}; /* 0 layout mode, 1 inspec
5 screen-off minutes, 6 suspend minutes (0: never), 5 screen-off minutes, 6 suspend minutes (0: never),
7 battery percent (-1: none), 8 battery charge-state, 9 battery seconds left, 7 battery percent (-1: none), 8 battery charge-state, 9 battery seconds left,
10 backlight brightness percent (-1: none), 11 osk visible (0/1), 10 backlight brightness percent (-1: none), 11 osk visible (0/1),
12 display rotation (0..3) */ 12 display rotation (0..3), 13 desktop shown (show-desktop hid the windows) */
/* ---- requests a guest made of the host (launch, focus, ...) ; drained by the shell after each call ---- */ /* ---- 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; typedef struct { int kind; int32_t n; char *s; } Req;
@@ -503,6 +504,10 @@ static wasm_trap_t *host_import(void *env, const wasm_val_vec_t *args, wasm_val_
if (results->size >= 1) results->data[0] = (wasm_val_t)WASM_I32_VAL(host_ints[12]); if (results->size >= 1) results->data[0] = (wasm_val_t)WASM_I32_VAL(host_ints[12]);
break; break;
case K_ROT_SET: push_req(22, a0, NULL); break; case K_ROT_SET: push_req(22, a0, NULL); break;
case K_DESK_SHOWN:
if (results->size >= 1) results->data[0] = (wasm_val_t)WASM_I32_VAL(host_ints[13] != 0);
break;
case K_DESK_TOGGLE: push_req(23, 0, NULL); break;
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; }
@@ -716,6 +721,8 @@ static int classify_import(const wasm_name_t *m, const wasm_name_t *f) {
if (!strcmp(iface, "osk") && !strcmp(fn, "set-visible")) return K_OSK_SET_VISIBLE; if (!strcmp(iface, "osk") && !strcmp(fn, "set-visible")) return K_OSK_SET_VISIBLE;
if (!strcmp(iface, "rotation") && !strcmp(fn, "current")) return K_ROT_CURRENT; if (!strcmp(iface, "rotation") && !strcmp(fn, "current")) return K_ROT_CURRENT;
if (!strcmp(iface, "rotation") && !strcmp(fn, "set-rotation")) return K_ROT_SET; if (!strcmp(iface, "rotation") && !strcmp(fn, "set-rotation")) return K_ROT_SET;
if (!strcmp(iface, "show-desktop") && !strcmp(fn, "is-shown")) return K_DESK_SHOWN;
if (!strcmp(iface, "show-desktop") && !strcmp(fn, "toggle")) return K_DESK_TOGGLE;
if (!strcmp(iface, "modules") && !strcmp(fn, "available")) return K_MOD_AVAILABLE; if (!strcmp(iface, "modules") && !strcmp(fn, "available")) return K_MOD_AVAILABLE;
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;
@@ -0,0 +1 @@
Show the desktop (Super+D): hide every window of the active workspace, and bring them back.
@@ -0,0 +1,8 @@
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
///|
fn wasmImportIsShown() -> Int = "chandra:desktop/show-desktop@0.1.0" "is-shown"
///|
fn wasmImportToggle() = "chandra:desktop/show-desktop@0.1.0" "toggle"
@@ -0,0 +1 @@
warnings = "-44"
@@ -0,0 +1,18 @@
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
///|
/// True while the windows are hidden and `toggle` would bring them back.
pub fn is_shown() -> Bool {
let result : Int = wasmImportIsShown();
let ret = (result != 0)
return ret
}
///|
/// Hide the windows to show the desktop, or (while it is shown) bring back the ones it hid.
pub fn toggle() -> Unit {
wasmImportToggle();
}
+27 -24
View File
@@ -66,6 +66,9 @@ fn wasmImportPublishOsk(p0 : Int) = "chandra:host/plasmoids@0.1.0" "publish-osk
///| ///|
fn wasmImportPublishRotation(p0 : Int) = "chandra:host/plasmoids@0.1.0" "publish-rotation" fn wasmImportPublishRotation(p0 : Int) = "chandra:host/plasmoids@0.1.0" "publish-rotation"
///|
fn wasmImportPublishDesktopShown(p0 : Int) = "chandra:host/plasmoids@0.1.0" "publish-desktop-shown"
///| ///|
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" 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"
@@ -88,16 +91,13 @@ fn wasmImportPickerStart() -> Int = "chandra:host/plasmoids@0.1.0" "picker-start
fn wasmImportPickerPoll(p0 : Int) = "chandra:host/plasmoids@0.1.0" "picker-poll" fn wasmImportPickerPoll(p0 : Int) = "chandra:host/plasmoids@0.1.0" "picker-poll"
///| ///|
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int = extern "wasm" fn mbt_ffi_load8_u(offset : Int) -> Int =
#|(func (param i32) (result i32) local.get 0 i32.load) #|(func (param i32) (result i32) local.get 0 i32.load8_u)
///| ///|
extern "wasm" fn mbt_ffi_free(position : Int) = #owned(bytes)
#|(func (param i32) local.get 0 call $moonbit.decref) extern "wasm" fn mbt_ffi_bytes2ptr(bytes : FixedArray[Byte]) -> Int =
#|(func (param i32) (result i32) local.get 0)
///|
extern "wasm" fn mbt_ffi_store32(offset : Int, value : Int) =
#|(func (param i32) (param i32) local.get 0 local.get 1 i32.store)
///| ///|
extern "wasm" fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String = extern "wasm" fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String =
@@ -113,29 +113,32 @@ extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
#| local.tee 1 i32.const 0 call $moonbit.init_array8 #| local.tee 1 i32.const 0 call $moonbit.init_array8
#| local.get 1) #| local.get 1)
///|
#owned(str)
extern "wasm" fn mbt_ffi_str2ptr(str : String) -> Int =
#|(func (param i32) (result i32) local.get 0)
///| ///|
extern "wasm" fn mbt_ffi_store64(offset : Int, value : Int64) = extern "wasm" fn mbt_ffi_store64(offset : Int, value : Int64) =
#|(func (param i32) (param i64) local.get 0 local.get 1 i64.store) #|(func (param i32) (param i64) local.get 0 local.get 1 i64.store)
///|
#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_store8(offset : Int, value : Int) = extern "wasm" fn mbt_ffi_store8(offset : Int, value : Int) =
#|(func (param i32) (param i32) local.get 0 local.get 1 i32.store8) #|(func (param i32) (param i32) local.get 0 local.get 1 i32.store8)
///| ///|
extern "wasm" fn mbt_ffi_load8_u(offset : Int) -> Int = extern "wasm" fn mbt_ffi_load64(offset : Int) -> Int64 =
#|(func (param i32) (result i32) local.get 0 i32.load8_u) #|(func (param i32) (result i64) local.get 0 i64.load)
///|
extern "wasm" fn mbt_ffi_store32(offset : Int, value : Int) =
#|(func (param i32) (param i32) local.get 0 local.get 1 i32.store)
///|
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_load32(offset : Int) -> Int =
#|(func (param i32) (result i32) local.get 0 i32.load)
@@ -110,6 +110,11 @@ fn wasmImportPublishRotation(p0 : Int) -> Unit {
abort("wasm-only host import") abort("wasm-only host import")
} }
///|
fn wasmImportPublishDesktopShown(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 { 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") abort("wasm-only host import")
@@ -146,17 +151,12 @@ fn wasmImportPickerPoll(p0 : Int) -> Unit {
} }
///| ///|
fn mbt_ffi_load32(offset : Int) -> Int { fn mbt_ffi_load8_u(offset : Int) -> Int {
abort("wasm-only") abort("wasm-only")
} }
///| ///|
fn mbt_ffi_free(position : Int) -> Unit { fn mbt_ffi_bytes2ptr(bytes : FixedArray[Byte]) -> Int {
abort("wasm-only")
}
///|
fn mbt_ffi_store32(offset : Int, value : Int) -> Unit {
abort("wasm-only") abort("wasm-only")
} }
@@ -170,32 +170,37 @@ fn mbt_ffi_malloc(size : Int) -> Int {
abort("wasm-only") abort("wasm-only")
} }
///|
fn mbt_ffi_str2ptr(str : String) -> Int {
abort("wasm-only")
}
///| ///|
fn mbt_ffi_store64(offset : Int, value : Int64) -> Unit { fn mbt_ffi_store64(offset : Int, value : Int64) -> Unit {
abort("wasm-only") abort("wasm-only")
} }
///|
fn mbt_ffi_bytes2ptr(bytes : FixedArray[Byte]) -> Int {
abort("wasm-only")
}
///|
fn mbt_ffi_load64(offset : Int) -> Int64 {
abort("wasm-only")
}
///| ///|
fn mbt_ffi_store8(offset : Int, value : Int) -> Unit { fn mbt_ffi_store8(offset : Int, value : Int) -> Unit {
abort("wasm-only") abort("wasm-only")
} }
///| ///|
fn mbt_ffi_load8_u(offset : Int) -> Int { fn mbt_ffi_load64(offset : Int) -> Int64 {
abort("wasm-only")
}
///|
fn mbt_ffi_store32(offset : Int, value : Int) -> Unit {
abort("wasm-only")
}
///|
fn mbt_ffi_free(position : Int) -> Unit {
abort("wasm-only")
}
///|
fn mbt_ffi_str2ptr(str : String) -> Int {
abort("wasm-only")
}
///|
fn mbt_ffi_load32(offset : Int) -> Int {
abort("wasm-only") abort("wasm-only")
} }
+12
View File
@@ -72,6 +72,7 @@ pub(all) enum Request {
SetBrightness(Int) SetBrightness(Int)
SetOskVisible(Bool) SetOskVisible(Bool)
SetRotation(Int) SetRotation(Int)
ToggleDesktop
} }
///| ///|
/// 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".
@@ -520,6 +521,13 @@ pub fn publish_rotation(rot : UInt) -> Unit {
wasmImportPublishRotation((rot).reinterpret_as_int()); wasmImportPublishRotation((rot).reinterpret_as_int());
}
///|
/// Whether show-desktop has the windows hidden (a toggle would bring them back).
pub fn publish_desktop_shown(shown : Bool) -> Unit {
wasmImportPublishDesktopShown((if shown { 1 } else { 0 }));
} }
///| ///|
pub fn publish_system(s : SystemSnapshot) -> Unit { pub fn publish_system(s : SystemSnapshot) -> Unit {
@@ -683,6 +691,10 @@ pub fn next_request() -> Request? {
Request::SetRotation(mbt_ffi_load32((return_area) + 8)) Request::SetRotation(mbt_ffi_load32((return_area) + 8))
} }
25 => {
Request::ToggleDesktop
}
_ => panic() _ => panic()
} }
+1
View File
@@ -15,3 +15,4 @@ starfield starfield-widget
gamerig-library gamerig-library-widget gamerig-library gamerig-library-widget
osk osk-widget osk osk-widget
rotate rotate-widget rotate rotate-widget
show-desktop show-desktop-widget
+8
View File
@@ -272,6 +272,7 @@ fn request_val(r : @wasm.HostRequest) -> @wt.Val {
) )
SetOskVisible(b) => Variant("set-osk-visible", Some(Bool(b))) SetOskVisible(b) => Variant("set-osk-visible", Some(Bool(b)))
SetRotation(n) => Variant("set-rotation", Some(S32(n))) SetRotation(n) => Variant("set-rotation", Some(S32(n)))
ToggleDesktop => Variant("toggle-desktop", None)
} }
} }
@@ -504,6 +505,13 @@ fn plasmoid_funcs() -> Array[(String, (Array[@wt.Val]) -> Array[@wt.Val])] {
none none
}, },
), ),
(
"publish-desktop-shown",
a => {
@wasm.publish_desktop_shown(a[0].to_bool())
none
},
),
( (
"publish-system", "publish-system",
a => { a => {
+8
View File
@@ -86,6 +86,14 @@ interface layout-control {
set-layout: func(mode: u32); set-layout: func(mode: u32);
} }
/// Show the desktop (Super+D): hide every window of the active workspace, and bring them back.
interface show-desktop {
/// True while the windows are hidden and `toggle` would bring them back.
is-shown: func() -> bool;
/// Hide the windows to show the desktop, or (while it is shown) bring back the ones it hid.
toggle: func();
}
/// The Interface Explorer: hover any system component to see its WIT. /// The Interface Explorer: hover any system component to see its WIT.
interface inspector { interface inspector {
is-on: func() -> bool; is-on: func() -> bool;
+4
View File
@@ -96,6 +96,8 @@ interface plasmoids {
publish-osk: func(visible: bool); publish-osk: func(visible: bool);
/// Current display orientation (0 = 0°, 1 = 90° CW, 2 = 180°, 3 = 270° CW). /// Current display orientation (0 = 0°, 1 = 90° CW, 2 = 180°, 3 = 270° CW).
publish-rotation: func(rot: u32); publish-rotation: func(rot: u32);
/// Whether show-desktop has the windows hidden (a toggle would bring them back).
publish-desktop-shown: func(shown: bool);
record system-snapshot { record system-snapshot {
cpu-permille: u32, cpu-permille: u32,
@@ -189,6 +191,8 @@ interface plasmoids {
set-osk-visible(bool), set-osk-visible(bool),
/// The rotation capability: set display orientation (0..3). /// The rotation capability: set display orientation (0..3).
set-rotation(s32), set-rotation(s32),
/// The show-desktop capability's `toggle`: hide the windows, or bring them back.
toggle-desktop,
} }
/// The next pending request, oldest first. /// The next pending request, oldest first.
next-request: func() -> option<request>; next-request: func() -> option<request>;
+7
View File
@@ -106,6 +106,7 @@ world plasmoid-host {
import game-library; import game-library;
import osk; import osk;
import rotation; import rotation;
import show-desktop;
export plasmoid; export plasmoid;
} }
@@ -187,6 +188,12 @@ world osk-widget {
import osk; import osk;
} }
/// Show Desktop button: hides the windows, a second click brings them back.
world show-desktop-widget {
include widget;
import show-desktop;
}
/// Display rotation button ("Rot"): rotates 90° clockwise on click. /// Display rotation button ("Rot"): rotates 90° clockwise on click.
world rotate-widget { world rotate-widget {
include widget; include widget;
+1
View File
@@ -0,0 +1 @@
Show Desktop button: hides the windows, a second click brings them back.
+2
View File
@@ -0,0 +1,2 @@
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
+2
View File
@@ -0,0 +1,2 @@
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
+1
View File
@@ -0,0 +1 @@
warnings = "-44"