Add backlight control to the shell and regenerate WIT bindings
CI / test (push) Canceled after 0s

- Add compositor/shell/backlight.mbt for backlight control in the shell
- Update wit/capabilities.wit and wit/host/plasmoids.wit, then regenerate the component and interface ffi.mbt bindings (mostly export reordering)
- Add world/launcher-widget/README.md
This commit is contained in:
nandi committed 2026-11-28 02:16:07 -08:00
1 parent 2e00009c79
commit 74235cb0ca
84 files changed
+1525 -864

No files matched your search

+7
View File
@@ -422,6 +422,11 @@ pub fn publish_power(screen_off : Int, suspend : Int) -> Unit {
@hostpl.publish_power(screen_off.reinterpret_as_uint(), suspend.reinterpret_as_uint())
}
///| Display backlight brightness percentage (0..100, or -1 if none).
pub fn publish_brightness(percent : Int) -> Unit {
@hostpl.publish_brightness(percent)
}
///| The battery (the `battery` capability): percent (-1: none), charge-state index, seconds left.
pub fn publish_battery(percent : Int, state : Int, secs_left : Int) -> Unit {
@hostpl.publish_battery(percent, state.reinterpret_as_uint(), secs_left.reinterpret_as_uint())
@@ -448,6 +453,7 @@ pub(all) enum HostRequest {
/// 1 power off, 2 restart).
SetScreenOff(Int)
SetSuspendAfter(Int)
SetBrightness(Int)
PowerAction(Int)
/// A network module's action (0 scan, 1 disconnect, 2/3 Wi-Fi off/on, 4/5 airplane mode
/// off/on, 6 connect, 7 forget), with the network name and password where it needs them.
@@ -487,6 +493,7 @@ pub fn next_request() -> HostRequest? {
Some(Screenshot(code)) => Some(Screenshot(code))
Some(SetScreenOff(m)) => Some(SetScreenOff(m))
Some(SetSuspendAfter(m)) => Some(SetSuspendAfter(m))
Some(SetBrightness(p)) => Some(SetBrightness(p))
Some(PowerAction(a)) => Some(PowerAction(a))
Some(Network(r)) => Some(Network(r.action, r.ssid, r.password))
Some(Shortcut(code)) => Some(Shortcut(code))
+7
View File
@@ -817,6 +817,11 @@ pub fn publish_power(screen_off : Int, suspend : Int) -> Unit {
c_host_set_int(6, suspend)
}
///| Publish current display backlight brightness percentage (0..100, or -1 if none).
pub fn publish_brightness(percent : Int) -> Unit {
c_host_set_int(10, percent)
}
///| Publish the battery (the `battery` capability): percent (-1: none), charge-state index,
/// seconds left (0: unknown).
pub fn publish_battery(percent : Int, state : Int, secs_left : Int) -> Unit {
@@ -846,6 +851,7 @@ pub(all) enum HostRequest {
/// 1 power off, 2 restart).
SetScreenOff(Int)
SetSuspendAfter(Int)
SetBrightness(Int)
PowerAction(Int)
/// A network module's action (0 scan, 1 disconnect, 2/3 Wi-Fi off/on, 4/5 airplane mode
/// off/on, 6 connect, 7 forget), with the network name and password where it needs them.
@@ -906,6 +912,7 @@ pub fn next_request() -> HostRequest? {
}
18 => Some(Shortcut(c_host_req_int()))
19 => Some(DefaultApp(c_host_req_int()))
20 => Some(SetBrightness(c_host_req_int()))
40 => Some(SetDesktop(c_host_req_int()))
44 => Some(FaceUnlock(c_host_req_int()))
45 => {
+10 -3
View File
@@ -60,7 +60,7 @@ enum {
K_SESSION_SETTINGS, K_SESSION_IS_ON, K_SESSION_SET,
K_APP_ICON,
K_SHOT_TAKE, K_SHOT_RECORD, K_SHOT_STOP, K_SHOT_IS_REC, K_SHOT_PTR, K_SHOT_SET_PTR,
K_PW_SCREEN, K_PW_SET_SCREEN, K_PW_SUSP, K_PW_SET_SUSP, K_PW_SUSPEND, K_PW_OFF, K_PW_REBOOT,
K_PW_SCREEN, K_PW_SET_SCREEN, K_PW_SUSP, K_PW_SET_SUSP, K_PW_BRIGHTNESS, K_PW_SET_BRIGHTNESS, K_PW_SUSPEND, K_PW_OFF, K_PW_REBOOT,
K_BAT_READ,
K_NET_STATUS, K_NET_LIST, K_NET_SCAN, K_NET_CONNECT, K_NET_DISCONNECT, K_NET_FORGET, K_NET_SET_WIFI,
K_NET_SET_AIRPLANE,
@@ -81,10 +81,11 @@ enum { T_APPS, T_WINDOWS, T_LAYOUTS, T_MODULES, T_INSTANCES, T_WALLPAPERS, T_SES
T_GL_STATUS = 26, T_GL_GAMES = 27, T_GL_MODES = 28, T_N = 32 };
typedef struct { uint8_t *data; size_t len; } Blob;
static Blob tables[T_N];
static int32_t host_ints[24] = {[7] = -1}; /* 0 layout mode, 1 inspector on, 2 current wallpaper, 3 session settings on (bit i: row i),
static int32_t host_ints[24] = {[7] = -1, [10] = -1}; /* 0 layout mode, 1 inspector on, 2 current wallpaper, 3 session settings on (bit i: row i),
4 screenshot state (bit 0 recording, bit 1 pointer in recordings),
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) */
/* ---- 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;
@@ -436,6 +437,10 @@ static wasm_trap_t *host_import(void *env, const wasm_val_vec_t *args, wasm_val_
break;
case K_PW_SET_SCREEN: push_req(13, a0, NULL); break;
case K_PW_SET_SUSP: push_req(14, a0, NULL); break;
case K_PW_BRIGHTNESS:
if (results->size >= 1) results->data[0] = (wasm_val_t)WASM_I32_VAL(host_ints[10]);
break;
case K_PW_SET_BRIGHTNESS: push_req(20, a0, NULL); break;
case K_PW_SUSPEND: push_req(15, 0, NULL); break; /* 15: power action n (0 suspend, 1 off, 2 restart) */
case K_PW_OFF: push_req(15, 1, NULL); break;
case K_PW_REBOOT: push_req(15, 2, NULL); break;
@@ -665,6 +670,8 @@ static int classify_import(const wasm_name_t *m, const wasm_name_t *f) {
if (!strcmp(iface, "power") && !strcmp(fn, "set-screen-off-minutes")) return K_PW_SET_SCREEN;
if (!strcmp(iface, "power") && !strcmp(fn, "suspend-minutes")) return K_PW_SUSP;
if (!strcmp(iface, "power") && !strcmp(fn, "set-suspend-minutes")) return K_PW_SET_SUSP;
if (!strcmp(iface, "power") && !strcmp(fn, "brightness")) return K_PW_BRIGHTNESS;
if (!strcmp(iface, "power") && !strcmp(fn, "set-brightness")) return K_PW_SET_BRIGHTNESS;
if (!strcmp(iface, "power") && !strcmp(fn, "suspend")) return K_PW_SUSPEND;
if (!strcmp(iface, "power") && !strcmp(fn, "power-off")) return K_PW_OFF;
if (!strcmp(iface, "power") && !strcmp(fn, "reboot")) return K_PW_REBOOT;