Skip to main content

PointerTable

Struct PointerTable 

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

The live pointers, plus the primary and hover-owner elections.

See the module docs for what those two roles mean and why they are not the same thing as PointerInfo::primary.

Implementations§

Source§

impl PointerTable

Source

pub const DEFAULT_CAP: usize = 10

How many pointers the table holds at once.

Ten: the maximum simultaneous contacts a Windows digitiser and a Wayland wl_touch seat both report. An eleventh arrival is refused at begin rather than evicting one of the ten, because evicting a contact mid-gesture is how a pinch turns into a fling.

Source

pub fn new() -> Self

An empty table with the default cap.

Source

pub fn with_cap(cap: usize) -> Self

An empty table that holds at most cap pointers. For tests that want to reach the cap without simulating ten fingers.

Source

pub fn cap(&self) -> usize

The cap this table was built with.

Source

pub fn get(&self, id: PointerId) -> Option<&PointerEntry>

The entry for id, if that pointer is live.

Source

pub fn get_mut(&mut self, id: PointerId) -> Option<&mut PointerEntry>

Mutable access to the entry for id, if that pointer is live.

Source

pub fn begin(&mut self, sample: &PointerSample) -> Option<PointerId>

Admit sample’s pointer, creating its entry on first sight and refreshing it afterwards.

Returns None — and traces the refusal — when the sample must not be dispatched at all:

A pointer already in the table is always refreshed, cap or no cap: the cap bounds how many pointers exist, never how many samples an admitted pointer may send.

Source

pub fn would_admit(&self, info: &PointerInfo) -> bool

Whether begin would accept info, without touching the table — and tracing the refusal, since a dropped sample that leaves no evidence is the hardest input bug there is.

The dispatcher asks this before it lowers a sample onto an event, so a refused pointer produces no event at all rather than one that is later discovered to have no entry behind it.

Source

pub fn admit( &mut self, info: PointerInfo, position: Point, is_down: bool, ) -> Option<PointerId>

The primitive behind begin, for the legacy WidgetEvent path, which has no PointerSample to hand.

is_down records position as the entry’s down_position.

Source

pub fn end(&mut self, id: PointerId) -> Option<PointerEntry>

Forget id, returning its entry if it was live.

Called for a contact’s Up or Cancel. A hovering-capable pointer is not ended by an Up — a mouse that releases a button is still there, still hovering, and its entry is what every legacy singular accessor reads.

Source

pub fn primary(&self) -> Option<&PointerEntry>

Teksilo’s single pointer: the one backing the legacy singular accessors. A mouse is preferred; failing that, the oldest live pointer.

Not to be confused with PointerInfo::primary — see the module docs.

Source

pub fn hover_owner(&self) -> Option<&PointerEntry>

The most recent hovering-capable pointer, if any is live.

Hover, enter/leave, the cursor and tooltip dwell all follow this pointer. A touch contact is never it.

Source

pub fn hover_owner_mut(&mut self) -> Option<&mut PointerEntry>

Mutable access to the hover owner’s entry.

Source

pub fn hover_owner_id(&self) -> Option<PointerId>

The hover owner’s id, without borrowing its entry.

Source

pub fn primary_id(&self) -> Option<PointerId>

The primary pointer’s id, without borrowing its entry.

Source

pub fn iter(&self) -> impl Iterator<Item = &PointerEntry> + '_

Every live pointer, oldest first.

Source

pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut PointerEntry> + '_

Every live pointer, mutably, oldest first.

Source

pub fn len(&self) -> usize

How many live pointers there are, hovering or not.

Source

pub fn is_empty(&self) -> bool

Whether no pointer is live.

Source

pub fn contact_count(&self) -> usize

How many live pointers are touching the surface — every contact, plus any hovering-capable pointer with a button held. This is the number a multi-touch recognizer counts fingers with; it is 0 for a resting mouse and 2 for a two-finger pinch.

Source

pub fn contains(&self, id: PointerId) -> bool

Whether id names a live pointer.

Source

pub fn retain_active(&mut self, arena: &WidgetArena)

Scrub widget references that no longer name an active node.

A rebuild mints fresh ids, so a hover target, a capture or a hover_within ancestor recorded before it can be dangling afterwards — and a dangling capture swallows every later Move and Up, because dispatch refuses an inactive target. Called from the tree’s post-layout revalidation after it has run the hover-owner’s own signal-firing recovery, so this is the sweep for every other pointer.

Source

pub fn release_captures_of(&mut self, widget: WidgetId)

Release every capture held on widget — it is going away, and a capture that outlives its owner strands the pointer.

Source

pub fn claim_hover_owner(&mut self, id: PointerId) -> Option<PointerId>

Hand the hover-owner role to id, reporting the pointer that lost it.

Called when a hovering-capable pointer produces a sample: the later sample wins, and the caller sends the displaced owner a PointerLeave. A contact is refused outright — it can never own hover — and so is a pointer that is not live.

Trait Implementations§

Source§

impl Clone for PointerTable

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PointerTable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PointerTable

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.