The wheel used to reach only the Interface Explorer dialog; clients never got wl_pointer.axis, and the login-session (KMS/libinput) backend dropped scroll events. - libinput axis events (wheel, touchpad, trackpoint) are queued as EV_AXIS and surface as InputEvent::Scroll(axis, value, discrete) in both the native and wasm (moonplasma:host/display seat-event.scroll) backends. - The nested backend keeps horizontal scroll and the host's axis_discrete notches. - The compositor sends axis_source(wheel) + axis_discrete/axis_value120 + axis + frame to the popup or window under the pointer; the explorer still takes the wheel while inspect mode is on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hjdz1uQ1y3GgazdKrR
150 lines
4.7 KiB
MoonBit
150 lines
4.7 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
|
|
}
|
|
///|
|
|
/// Wheel/touchpad scroll: axis (0 vertical, 1 horizontal), distance in pixels (positive =
|
|
/// down/right), wheel notches (0 when not from a wheel).
|
|
pub(all) struct ScrollDelta {
|
|
axis : UInt; value : Double; discrete : Int
|
|
}
|
|
///|
|
|
pub(all) enum SeatEvent {
|
|
PointerMove(PointerPos)
|
|
PointerButton(KeyState)
|
|
Key(KeyState)
|
|
Modifiers(Modifiers)
|
|
Scroll(ScrollDelta)
|
|
}
|
|
///|
|
|
/// 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 host framebuffer (what `raster.submit` drew) on the output.
|
|
pub fn present_frame() -> Unit {
|
|
|
|
wasmImportPresentFrame();
|
|
|
|
}
|
|
///|
|
|
/// 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 * 32)
|
|
|
|
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()})
|
|
}
|
|
4 => {
|
|
|
|
SeatEvent::Scroll(ScrollDelta::{axis : (mbt_ffi_load32((iter_base) + 8)).reinterpret_as_uint(), value : mbt_ffi_loadf64((iter_base) + 16), discrete : mbt_ffi_load32((iter_base) + 24)})
|
|
}
|
|
_ => 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();
|
|
|
|
}
|
|
|