Skip to main content

PointerIdAllocator

Struct PointerIdAllocator 

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

Mints PointerIds and maps a backend’s reused contact ids onto them.

One instance per process, reached through PointerIdAllocator::global. The mapping is (device, os_id) -> PointerId, established at begin and torn down at end; get resolves the samples in between.

Implementations§

Source§

impl PointerIdAllocator

Source

pub fn global() -> &'static Self

The process-global allocator.

Source

pub fn begin(&self, device: BackendDeviceKey, os_id: u64) -> PointerId

Mint a fresh id for a press and remember it for (device, os_id).

A second begin on a key that is already live replaces the mapping and returns a new id — a backend that drops an Up (a lost contact, a window that stopped receiving events mid-gesture) must not strand the next press on the old identity.

Source

pub fn get(&self, device: BackendDeviceKey, os_id: u64) -> Option<PointerId>

The id minted for a live (device, os_id), if the contact is still down. None after end, which is what makes a reused OS id resolve to a new PointerId rather than the stale one.

Source

pub fn end(&self, device: BackendDeviceKey, os_id: u64) -> Option<PointerId>

Forget the mapping for a lifted contact. Idempotent; returns the id that was live, if any.

Source

pub fn live_count(&self) -> usize

Number of contacts currently mapped. Test/diagnostic helper.

Trait Implementations§

Source§

impl Debug for PointerIdAllocator

Source§

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

Formats the value using the given formatter. 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> 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 = !

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.