Skip to main content

PointerDevice

Struct PointerDevice 

Source
pub struct PointerDevice { /* private fields */ }
Expand description

LPAR-04 §8 Pointer input device adapter.

Owns the canonical recognizer chain:

raw → DragRecognizer → TapRecognizer → LongPressRecognizer → DoubleTapRecognizer → dispatch

Note 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:

  1. PressDown (debounced) arms the long-press timer.
  2. DragStart cancels TapRecognizer (no PressDown emitted) and also explicitly cancels LongPressRecognizer (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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.