Skip to main content

PointerBackend

Trait PointerBackend 

Source
pub trait PointerBackend {
    // Required methods
    fn translate(
        &mut self,
        event: &BackendEvent<'_>,
        now: EventTime,
    ) -> Vec<InputSample>;
    fn capabilities(&self) -> BackendCaps;
    fn cancel_all(&mut self, now: EventTime) -> Vec<InputSample>;
}
Expand description

Turns OS packets into InputSamples.

One instance per window: a backend owns per-window state (the live contact set, the scroll-phase machine, the modifier and scale factor) and two windows must not share it.

§Contract

  • Every contact that produces a PointerPhase::Down sample is terminated by exactly one Up or one Cancel — never both, never neither. cancel_all exists so a caller can honour that when the window goes away.
  • The EventTimes a backend stamps are monotone non-decreasing within one stream. now is supplied by the caller from the tree’s one clock, so a backend never reads Instant::now().
  • A backend never allocates a PointerId itself: it mints through PointerIdAllocator, which is what makes a reused OS contact id resolve to a fresh identity.

Required Methods§

Source

fn translate( &mut self, event: &BackendEvent<'_>, now: EventTime, ) -> Vec<InputSample>

Translate one OS packet. Returns every sample it implies, in dispatch order; an empty vector is a normal, common answer (a filtered phantom, a touch packet with the kill switch off, an unmapped mouse button).

Source

fn capabilities(&self) -> BackendCaps

What this backend can report. See BackendCaps.

Source

fn cancel_all(&mut self, now: EventTime) -> Vec<InputSample>

Terminate every live contact with a Cancel sample and forget it.

Called when the window loses the input it was receiving — focus loss, a close, a compositor grab — so that the “every Down is terminated” contract survives a stream that simply stops.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§