Skip to main content

PointerInfo

Struct PointerInfo 

Source
#[non_exhaustive]
pub struct PointerInfo { pub id: PointerId, pub kind: PointerKind, pub primary: bool, pub buttons: ButtonMask, pub axes: PointerAxes, pub time: EventTime, pub palm: bool, }
Expand description

Everything that identifies and describes the pointer producing a sample.

Carried by PointerSample, ScrollSample and by every pointer-bearing WidgetEvent — the pointer, scroll and cancel variants alike.

#[non_exhaustive]: construct one through mouse / touch and adjust fields, so a later field cannot break a call site.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§id: PointerId

Which pointer this is. See the module docs on per-press identity.

§kind: PointerKind

What kind of device it is — the axis gesture tuning reads.

§primary: bool

The W3C Pointer Events isPrimary flag, which is per kind: every mouse sample is primary, and so is the first contact of a touch sequence. On a machine with both, a mouse and a first finger are both primary at once. It is a property of the sample, set by whoever produced it, and PointerTable never rewrites it.

Not the framework’s singular pointer. The one that drives the legacy singular signals — hovered, the cursor, the one PointerDown a widget that knows nothing of multi-touch sees — is PointerTable::primary, a table-level election that exactly one live pointer holds and that a mouse always wins. A third notion, PointerTable::hover_owner, is the most recent hovering-capable pointer. table.rs’s module docs separate all three; reading this flag as either of the others is the mistake the separation exists to prevent.

§buttons: ButtonMask

The buttons held after this sample is applied. A press sets its own bit; a release clears it. Empty for a hovering pointer.

§axes: PointerAxes

The continuous axes, where the device reports them.

§time: EventTime

When the backend says this sample happened, on the tree’s timeline.

§palm: bool

The digitizer classified this contact as a palm rather than a deliberate touch.

Only a backend that advertises reports_palm ever sets it; everything else leaves it false, which is why no existing call site changes meaning. A flagged sample is refused by PointerTable::begin and never reaches a widget: rejecting it at the table is what keeps a hand resting on a tablet from opening menus, and it is one decision rather than one per recognizer.

Implementations§

Source§

impl PointerInfo

Source

pub const fn mouse(time: EventTime) -> Self

The mouse: PointerId::MOUSE, PointerKind::Mouse, primary, no buttons held, no axes.

This is what every legacy WidgetEvent constructor defaults to, so a call site that says nothing about pointers keeps meaning exactly what it meant before the touch programme.

Source

pub const fn touch(id: PointerId, time: EventTime) -> Self

A touch contact, with the W3C per-kind primary flag clear. A producer that knows this is the first contact of a sequence sets it; the platform translator does. The pointer table’s own election is a separate thing and never writes this field.

Source

pub const fn is_direct(&self) -> bool

Whether the user points at the pixel directly — see PointerKind::is_direct.

Source

pub const fn is_coarse(&self) -> bool

Whether the contact patch is large enough that the reported point is an estimate — see PointerKind::is_coarse.

Source

pub const fn is_precise(&self) -> bool

Whether the reported position is accurate to about a pixel — see PointerKind::is_precise.

Source

pub fn effective_pressure(&self) -> f32

The pressure a consumer should read: the reported value if the device gave one, else 0.5 while any button is down, else 0.0.

This is the W3C Pointer Events Level 3 rule for pressure, and it exists so a pressure-sensitive surface (a brush, a force-touch affordance) has a defined answer for a mouse without special-casing it.

Trait Implementations§

Source§

impl Clone for PointerInfo

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 Copy for PointerInfo

Source§

impl Debug for PointerInfo

Source§

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

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

impl PartialEq for PointerInfo

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for PointerInfo

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.