#[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 (from stage 1 of the
event-shape landing) by the scroll and cancel WidgetEvents.
#[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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: PointerIdWhich pointer this is. See the module docs on per-press identity.
kind: PointerKindWhat kind of device it is — the axis gesture tuning reads.
primary: boolThe 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.
The buttons held after this sample is applied. A press sets its own bit; a release clears it. Empty for a hovering pointer.
axes: PointerAxesThe continuous axes, where the device reports them.
time: EventTimeWhen the backend says this sample happened, on the tree’s timeline.
palm: boolThe 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
impl PointerInfo
Sourcepub const fn mouse(time: EventTime) -> Self
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.
Sourcepub const fn touch(id: PointerId, time: EventTime) -> Self
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.
Sourcepub const fn is_direct(&self) -> bool
pub const fn is_direct(&self) -> bool
Whether the user points at the pixel directly — see
PointerKind::is_direct.
Sourcepub const fn is_coarse(&self) -> bool
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.
Sourcepub const fn is_precise(&self) -> bool
pub const fn is_precise(&self) -> bool
Whether the reported position is accurate to about a pixel — see
PointerKind::is_precise.
Sourcepub fn effective_pressure(&self) -> f32
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
impl Clone for PointerInfo
Source§fn clone(&self) -> PointerInfo
fn clone(&self) -> PointerInfo
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more