pub struct PointerDevice { /* private fields */ }Expand description
LPAR-04 §8 Pointer input device adapter.
Owns the canonical recognizer chain:
raw → DragRecognizer → TapRecognizer → LongPressRecognizer → DoubleTapRecognizer → dispatchNote on chain order vs. spec: LPAR-04 §8.3 lists the chain as
raw → Drag → LongPress → Tap → DoubleTap. In practice, the
LongPressRecognizer implementation arms on PressDown (the output of
TapRecognizer), not on raw PointerDown. The chain is therefore
corrected to Drag → Tap → LongPress → DoubleTap so that:
PressDown(debounced) arms the long-press timer.DragStartcancelsTapRecognizer(noPressDownemitted) and also explicitly cancelsLongPressRecognizer(safety — e.g. if a contact moved past the drag threshold after the long-press fired).
This preserves the INPUT-00 §6.2 / LPAR-04 §9.4 cancellation contract.
§Scroll integration (LPAR-05 §7)
When constructed with with_scroll, an owned
ScrollController sits above the recognizer chain. On every
DragStart/DragMove/DragEnd the controller is offered the event
first. If the controller activates a scroll session (it found a
SCROLLABLE ancestor), the drag event is not re-dispatched to the
object tree as a normal gesture — scrolling and gesture dispatch are
mutually exclusive for the same contact (LPAR-05 §7.2). Dirty rects
are accumulated in an internal Vec<Rect> and can be drained with
take_dirty.
Feed raw hardware events with process and call
tick once per frame tick to drive the long-press,
double-tap timers, and (if enabled) the scroll throw tween. Each
resulting stream event is dispatched into the tree via
dispatch_object_event(root, DispatchInput::Pointer { x, y, event }).
Implementations§
Source§impl PointerDevice
impl PointerDevice
Sourcepub fn new(frame_hz: u32) -> Self
pub fn new(frame_hz: u32) -> Self
Create a pointer device with the default recognizer thresholds at the given frame rate.
frame_hz is used to convert the duration constants in
crate::gesture from milliseconds to ticks.
Scroll integration is disabled by this constructor. Use
with_scroll to enable it.
Sourcepub fn with_long_press_config(frame_hz: u32, lp_config: LongPressConfig) -> Self
pub fn with_long_press_config(frame_hz: u32, lp_config: LongPressConfig) -> Self
Create a pointer device with custom long-press thresholds.
Use this to override the default 400 ms / 100 ms timings.
Scroll integration is disabled by this constructor. Use
with_scroll on the returned instance to enable
it.
Sourcepub fn with_scroll(self, config: ScrollConfig) -> Self
pub fn with_scroll(self, config: ScrollConfig) -> Self
Attach a ScrollController to this device, enabling LPAR-05
drag→scroll composition.
Can be called with a custom ScrollConfig or with the default via
ScrollConfig::default().
§Composition rule (LPAR-05 §7.2)
A drag event that activates a scroll session is consumed by the
controller and MUST NOT also be dispatched as a normal drag gesture
to the object tree. Use take_dirty after each
process / tick call to drain the
accumulated viewport dirty rects and forward them to the LPAR-03
invalidation planner.
Sourcepub fn take_dirty(&mut self) -> Vec<Rect>
pub fn take_dirty(&mut self) -> Vec<Rect>
Drain and return all viewport dirty Rects accumulated since the
last call.
Each rect corresponds to the viewport of a scroll container whose
offset changed during the last process or
tick call. Forward these to the LPAR-03 invalidation
planner so the display driver repaints the affected areas.
Returns an empty Vec when no scroll activity occurred or when scroll
integration is disabled.
Sourcepub fn process(&mut self, root: &mut ObjectNode, raw: Event) -> Disposition
pub fn process(&mut self, root: &mut ObjectNode, raw: Event) -> Disposition
Feed one raw hardware event through the recognizer chain and dispatch any resulting stream events to the tree.
Raw events (PointerDown/Move/Up) traverse the chain in order.
Returns the Disposition of the last dispatch that was made for
this event, or Disposition::NoTarget when the chain produced no
dispatchable output.
When scroll integration is enabled (see with_scroll):
drag events (DragStart/DragMove/DragEnd) are offered to the
ScrollController first. If the controller activates or continues a
scroll session, the drag is suppressed from normal object-tree
dispatch (LPAR-05 §7.2). Dirty rects are accumulated; drain them with
take_dirty.
Sourcepub fn tick(&mut self, root: &mut ObjectNode) -> Disposition
pub fn tick(&mut self, root: &mut ObjectNode) -> Disposition
Advance all time-based recognizers one tick and dispatch any emitted stream events to the tree.
Call this once per Event::Tick. Drives the long-press recognizer
(for LongPress/LongPressRepeat delivery), the double-tap window
timer (for deferred single-tap delivery), and — when scroll integration
is enabled — the scroll throw/snap-settle tween. Dirty rects from
throw ticks are accumulated; drain them with
take_dirty.
Returns the Disposition of the last dispatch that occurred during
this tick, or Disposition::NoTarget if the tick produced no output.