pub enum PointerMode {
Free,
Confined,
Locked,
}Expand description
Where the pointer is allowed to go.
Variants§
Free
Normal: the pointer moves freely and can leave the window.
Confined
The pointer stays inside the window but keeps moving visibly.
What a strategy game’s edge-scrolling wants. Requires
ShellCaps::POINTER_CONFINE.
Locked
The pointer is pinned in place and only relative motion is reported.
What a first-person camera wants. Requires
ShellCaps::POINTER_LOCK, and in
practice also
ShellCaps::RAW_POINTER_MOTION
— see ShellCaps::has_mouselook.
While locked, ShellEvent::PointerMotion
carries abs: None: there is no meaningful absolute position, and
reporting the frozen one would make anything that reads it appear to
work until the day it does not.
Implementations§
Source§impl PointerMode
impl PointerMode
Sourcepub const fn is_captured(self) -> bool
pub const fn is_captured(self) -> bool
Whether this mode constrains the pointer at all.
Sourcepub const fn required_cap(self) -> ShellCaps
pub const fn required_cap(self) -> ShellCaps
The capability a shell must report for this mode to be settable.
Free needs none, so it returns an empty set — which is
what makes caps.contains(mode.required_cap()) correct for all three
without a special case at the call site.
Sourcepub const fn as_str(self) -> &'static str
pub const fn as_str(self) -> &'static str
What this mode is called in a
ShellError::Unsupported.
Every backend needs this string in
set_pointer_mode and each one used
to spell the table again, with an unreachable!() for
Free on the grounds that it needs no capability. That
reasoning is correct today and is a panic the day a mode is added, so
the function is total instead.