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::Downsample is terminated by exactly oneUpor oneCancel— never both, never neither.cancel_allexists so a caller can honour that when the window goes away. - The
EventTimes a backend stamps are monotone non-decreasing within one stream.nowis supplied by the caller from the tree’s one clock, so a backend never readsInstant::now(). - A backend never allocates a
PointerIditself: it mints throughPointerIdAllocator, which is what makes a reused OS contact id resolve to a fresh identity.
Required Methods§
Sourcefn translate(
&mut self,
event: &BackendEvent<'_>,
now: EventTime,
) -> Vec<InputSample>
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).
Sourcefn capabilities(&self) -> BackendCaps
fn capabilities(&self) -> BackendCaps
What this backend can report. See BackendCaps.
Sourcefn cancel_all(&mut self, now: EventTime) -> Vec<InputSample>
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".