CI / test (push) Failing after 1m13s
New moonplasma:host/display import (open, poll, present, cursor, input events, close). The wasmtime host implements it by compiling the compositor's own kms shim (libseat + DRM/KMS + libinput + xkbcommon) via build.rs (feature drm, default on), so the native and wasm backends share one implementation. compositor/kms gets a wasm backend with the same API, and the shared app loop gains --drm. - session: install.py installs the host, compositor.wasm, fonts, config, wit and modules and the display-manager entry (--native keeps the old native session); the launcher starts the host when installed. just run-drm / install-session use the wasm compositor; *-native keep the old. - compositor.wasm moves to build/ (out of build/components, where the module catalog scans). Verified: component builds with the new import, host instantiates it and renders frames, installed layout (fonts/modules/theme from the share dir) renders correctly in a sandbox, native build and tests unchanged. NOT exercised on a real login VT. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
132 lines
4.0 KiB
MoonBit
132 lines
4.0 KiB
MoonBit
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
|
|
///|
|
|
pub(all) struct Output {
|
|
width : UInt; height : UInt; keymap : FixedArray[Byte]
|
|
}
|
|
///|
|
|
pub(all) struct PointerPos {
|
|
x : Double; y : Double
|
|
}
|
|
///|
|
|
/// A button or key as an evdev code, pressed or released.
|
|
pub(all) struct KeyState {
|
|
code : UInt; pressed : Bool
|
|
}
|
|
///|
|
|
pub(all) struct Modifiers {
|
|
depressed : UInt; latched : UInt; locked : UInt; group : UInt
|
|
}
|
|
///|
|
|
pub(all) enum SeatEvent {
|
|
PointerMove(PointerPos)
|
|
PointerButton(KeyState)
|
|
Key(KeyState)
|
|
Modifiers(Modifiers)
|
|
}
|
|
///|
|
|
/// Take over the first connected output and the seat's input. None, with the reason on the
|
|
/// host's stderr, when this is not an active login VT.
|
|
pub fn open() -> Output? {
|
|
|
|
let return_area = mbt_ffi_malloc(20)
|
|
wasmImportOpen(return_area);
|
|
|
|
let lifted : Output? = match mbt_ffi_load8_u((return_area) + 0) {
|
|
0 => Option::None
|
|
1 => {
|
|
|
|
let result = mbt_ffi_ptr2bytes(mbt_ffi_load32((return_area) + 12), mbt_ffi_load32((return_area) + 16))
|
|
|
|
Option::Some(Output::{width : (mbt_ffi_load32((return_area) + 4)).reinterpret_as_uint(), height : (mbt_ffi_load32((return_area) + 8)).reinterpret_as_uint(), keymap : result})
|
|
}
|
|
_ => panic()
|
|
}
|
|
let ret = lifted
|
|
mbt_ffi_free(return_area)
|
|
return ret
|
|
|
|
}
|
|
///|
|
|
/// Service the seat, DRM and input fds without blocking. False once the user asked to quit
|
|
/// (Ctrl+Alt+Backspace).
|
|
pub fn poll() -> Bool {
|
|
|
|
let result : Int = wasmImportPoll();
|
|
let ret = (result != 0)
|
|
return ret
|
|
|
|
}
|
|
///|
|
|
/// True when a new frame can be presented (seat active, no page flip in flight).
|
|
pub fn frame_ready() -> Bool {
|
|
|
|
let result : Int = wasmImportFrameReady();
|
|
let ret = (result != 0)
|
|
return ret
|
|
|
|
}
|
|
///|
|
|
/// Show an RGBA8888 frame of `width` x `height` (it must match the output mode).
|
|
pub fn present(pixels : FixedArray[Byte], width : UInt, height : UInt) -> Unit {
|
|
|
|
let ptr = mbt_ffi_bytes2ptr(pixels)
|
|
|
|
wasmImportPresent(ptr, pixels.length(), (width).reinterpret_as_int(), (height).reinterpret_as_int());
|
|
mbt_ffi_free(ptr)
|
|
|
|
}
|
|
///|
|
|
/// Show the cursor for a wp_cursor_shape_v1 value.
|
|
pub fn set_cursor_shape(shape : UInt) -> Unit {
|
|
|
|
wasmImportSetCursorShape((shape).reinterpret_as_int());
|
|
|
|
}
|
|
///|
|
|
/// Input queued since the last call.
|
|
pub fn take_input() -> Array[SeatEvent] {
|
|
|
|
let return_area = mbt_ffi_malloc(8)
|
|
wasmImportTakeInput(return_area);
|
|
|
|
let array : Array[SeatEvent] = [];
|
|
for index = 0; index < (mbt_ffi_load32((return_area) + 4)); index = index + 1 {
|
|
let iter_base = (mbt_ffi_load32((return_area) + 0)) + (index * 24)
|
|
|
|
let lifted = match (mbt_ffi_load8_u((iter_base) + 0)) {
|
|
0 => {
|
|
|
|
SeatEvent::PointerMove(PointerPos::{x : mbt_ffi_loadf64((iter_base) + 8), y : mbt_ffi_loadf64((iter_base) + 16)})
|
|
}
|
|
1 => {
|
|
|
|
SeatEvent::PointerButton(KeyState::{code : (mbt_ffi_load32((iter_base) + 8)).reinterpret_as_uint(), pressed : (mbt_ffi_load8_u((iter_base) + 12) != 0)})
|
|
}
|
|
2 => {
|
|
|
|
SeatEvent::Key(KeyState::{code : (mbt_ffi_load32((iter_base) + 8)).reinterpret_as_uint(), pressed : (mbt_ffi_load8_u((iter_base) + 12) != 0)})
|
|
}
|
|
3 => {
|
|
|
|
SeatEvent::Modifiers(Modifiers::{depressed : (mbt_ffi_load32((iter_base) + 8)).reinterpret_as_uint(), latched : (mbt_ffi_load32((iter_base) + 12)).reinterpret_as_uint(), locked : (mbt_ffi_load32((iter_base) + 16)).reinterpret_as_uint(), group : (mbt_ffi_load32((iter_base) + 20)).reinterpret_as_uint()})
|
|
}
|
|
_ => panic()
|
|
}
|
|
|
|
array.push(lifted)
|
|
}
|
|
mbt_ffi_free(mbt_ffi_load32((return_area) + 0))
|
|
let ret = array
|
|
mbt_ffi_free(return_area)
|
|
return ret
|
|
|
|
}
|
|
///|
|
|
/// Restore the previous video mode and release the seat.
|
|
pub fn close() -> Unit {
|
|
|
|
wasmImportClose();
|
|
|
|
}
|
|
|