Every touch was turned into a mouse drag in the seat code, which selects text instead of scrolling. The seat now reports raw touches and the compositor routes them: to the app as wl_touch on its own content, and to the pointer (tap, drag, hold for right click, as before) everywhere else and for apps that don't listen to touches. The cursor is hidden while fingers are in use. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
97 lines
3.2 KiB
MoonBit
97 lines
3.2 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)
|
|
}
|
|
|
|
///| Rotate the output (`0=0`, `1=90 CW`, `2=180`, `3=270 CW`); returns new logical `(w, h)`.
|
|
pub fn Kms::set_rotation(_self : Kms, rot : Int) -> (Int, Int) {
|
|
let p = @hostdisplay.set_rotation(rot.reinterpret_as_uint()).reinterpret_as_int()
|
|
((p >> 16) & 0xFFFF, p & 0xFFFF)
|
|
}
|
|
|
|
///| 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))
|
|
TouchDown(t) => out.push(Touch(Down(t.id, t.x, t.y)))
|
|
TouchMotion(t) => out.push(Touch(Motion(t.id, t.x, t.y)))
|
|
TouchUp(id) => out.push(Touch(Up(id)))
|
|
TouchCancel => out.push(Touch(Cancel))
|
|
TouchPresent => out.push(Touch(Present))
|
|
}
|
|
}
|
|
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] {
|
|
[]
|
|
}
|