CI / test (push) Failing after 18s
- Settings gets a Power tab (fourth; key 4 or SettingsTab::Power): the battery when there is
one (the system capability), "Turn screen off after" (Never, 1 min ... 1 hour; default 10 min)
and "Suspend after" (Never, 5 min ... 2 hours; default never), a click stepping through the
choices, and Suspend / Restart / Power off now. Restart and Power off need a second click.
- New `power` capability (screen-off-minutes, suspend-minutes and setters, suspend, power-off,
reboot), served by the wasmer stub (host ints 5/6, requests 13-15) and host-wasm
(publish-power, set-screen-off / set-suspend-after / power-action).
- The timeouts are kept in state.edn as :power {:screen-off N :suspend N} when not the defaults.
- Login session only (compositor/host/power.mbt): input restarts the idle time; power_tick,
run every pass of the main loop (an idle loop still wakes about once a second), turns the
screen off through DPMS and back on at the next input, and suspends once per idle spell.
Monotonic time stops in suspend, so a resumed machine waits for input and a new idle spell.
Suspend, restart and power off run `systemctl <verb> || loginctl <verb>` (logind, so its
inhibitors and polkit rules apply); a nested window only shows a notice.
- Display: chandra:host/display set-power and Kms::set_power; the shared C shim sets the
connector's legacy DPMS property, shows no frames while off (frame_ready false, so the idle
loop still sleeps), redoes the modeset when turned on, and keeps the screen off across a VT
switch.
- components/screenshot bindings regenerated (they were stale: the module didn't build).
- Tests: idle timer sequence, the Power tab driving the shell (timeouts, two-click power off),
the state.edn round trip, a host-wasm test of the tab, and logind commands.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hgxf6exeYrDGcy4WW3
86 lines
2.7 KiB
MoonBit
86 lines
2.7 KiB
MoonBit
///| Wasm display backend: the same API as kms_native.mbt, but the host owns the display and the
|
|
/// seat (`chandra:host/display`). The component sends frames out and reads events in.
|
|
|
|
///|
|
|
pub(all) struct Kms {
|
|
width : Int
|
|
height : Int
|
|
keymap : Bytes
|
|
}
|
|
|
|
///| Take over the first connected output and the seat's input. None when this is not an active
|
|
/// login VT (the host prints why).
|
|
pub fn Kms::open() -> Kms? {
|
|
match @hostdisplay.open() {
|
|
None => None
|
|
Some(o) =>
|
|
Some({
|
|
width: o.width.reinterpret_as_int(),
|
|
height: o.height.reinterpret_as_int(),
|
|
keymap: Bytes::from_fixedarray(o.keymap),
|
|
})
|
|
}
|
|
}
|
|
|
|
///| Service the seat, DRM and input fds. False once Ctrl+Alt+Backspace was pressed.
|
|
pub fn Kms::poll(_self : Kms) -> Bool {
|
|
@hostdisplay.poll()
|
|
}
|
|
|
|
///| True when a new frame can be presented (seat active, no page flip in flight).
|
|
pub fn Kms::frame_ready(_self : Kms) -> Bool {
|
|
@hostdisplay.frame_ready()
|
|
}
|
|
|
|
///| Present a composed frame (its size must match the output mode).
|
|
pub fn Kms::present(_self : Kms, pixmap : @renderer.Pixmap) -> Unit {
|
|
@hostdisplay.present(
|
|
pixmap.data,
|
|
pixmap.width.reinterpret_as_uint(),
|
|
pixmap.height.reinterpret_as_uint(),
|
|
)
|
|
}
|
|
|
|
///| Show the host framebuffer (what the host rasteriser drew) on the output: nothing is copied
|
|
/// through this program.
|
|
pub fn Kms::present_frame(_self : Kms) -> Unit {
|
|
@hostdisplay.present_frame()
|
|
}
|
|
|
|
///| Turn the screen on or off (DPMS). While it is off no frame is shown (`frame_ready` is
|
|
/// false); on shows the last frame again.
|
|
pub fn Kms::set_power(_self : Kms, on : Bool) -> Unit {
|
|
@hostdisplay.set_power(on)
|
|
}
|
|
|
|
///| Show the cursor for a wp_cursor_shape_v1 value.
|
|
pub fn Kms::set_cursor_shape(_self : Kms, shape : UInt) -> Unit {
|
|
@hostdisplay.set_cursor_shape(shape)
|
|
}
|
|
|
|
///| Input queued since the last call, in the compositor's event type.
|
|
pub fn Kms::take_input(_self : Kms) -> Array[@nested.InputEvent] {
|
|
let out : Array[@nested.InputEvent] = []
|
|
for ev in @hostdisplay.take_input() {
|
|
match ev {
|
|
PointerMove(p) => out.push(PointerMove(p.x, p.y))
|
|
PointerButton(k) => out.push(PointerButton(k.code, k.pressed))
|
|
Key(k) => out.push(Key(k.code, k.pressed))
|
|
Modifiers(m) => out.push(Modifiers(m.depressed, m.latched, m.locked, m.group))
|
|
Scroll(d) => out.push(Scroll(d.axis, d.value, d.discrete))
|
|
}
|
|
}
|
|
out
|
|
}
|
|
|
|
///| Restore the previous video mode and release the seat.
|
|
pub fn Kms::close(_self : Kms) -> Unit {
|
|
@hostdisplay.close()
|
|
}
|
|
|
|
///| The fds an idle loop blocks on for the display: none here, since the host's
|
|
/// `sys.wait-readable` adds its own seat, DRM and input fds while the display is open.
|
|
pub fn Kms::wait_fds(_self : Kms) -> Array[Int] {
|
|
[]
|
|
}
|