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

+8
View File
@@ -427,6 +427,11 @@ pub fn publish_rotation(rot : Int) -> Unit {
@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).
pub fn publish_power(screen_off : Int, suspend : Int) -> Unit {
@hostpl.publish_power(screen_off.reinterpret_as_uint(), suspend.reinterpret_as_uint())
@@ -487,6 +492,8 @@ pub(all) enum HostRequest {
SetOskVisible(Bool)
/// The rotation capability: set display orientation (0..3).
SetRotation(Int)
/// The show-desktop capability's `toggle`: hide the windows, or bring back the ones it hid.
ToggleDesktop
} derive(Eq, Debug)
///|
@@ -518,6 +525,7 @@ pub fn next_request() -> HostRequest? {
Some(GameLibrary(r)) => Some(GameLibrary(r.action, r.game, r.mode))
Some(SetOskVisible(v)) => Some(SetOskVisible(v))
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)
}
///| 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).
pub fn publish_power(screen_off : Int, suspend : Int) -> Unit {
c_host_set_int(5, screen_off)
@@ -905,6 +910,8 @@ pub(all) enum HostRequest {
SetOskVisible(Bool)
/// The rotation capability: set display orientation (0..3).
SetRotation(Int)
/// The show-desktop capability's `toggle`: hide the windows, or bring back the ones it hid.
ToggleDesktop
} derive(Eq, Debug)
///|
@@ -949,6 +956,7 @@ pub fn next_request() -> HostRequest? {
20 => Some(SetBrightness(c_host_req_int()))
21 => Some(SetOskVisible(c_host_req_int() != 0))
22 => Some(SetRotation(c_host_req_int()))
23 => Some(ToggleDesktop)
40 => Some(SetDesktop(c_host_req_int()))
44 => Some(FaceUnlock(c_host_req_int()))
45 => {
+9 -2
View File
@@ -69,7 +69,8 @@ enum {
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_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;
@@ -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),
7 battery percent (-1: none), 8 battery charge-state, 9 battery seconds left,
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 ---- */
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]);
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_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; }
@@ -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, "rotation") && !strcmp(fn, "current")) return K_ROT_CURRENT;
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, "loaded")) return K_MOD_LOADED;
if (!strcmp(iface, "modules") && !strcmp(fn, "load-module")) return K_MOD_LOAD;