mirror of
https://github.com/storytold/winit.git
synced 2026-11-29 09:44:58 +01:00
Use the reported axis source so wheel, wheel-tilt and continuous-source scroll events report `TouchPhase::Moved` instead of starting a finger gesture that never ends; egui then follows modifier release instead of keeping Ctrl zoom latched. Finger momentum is unchanged. The phase policy lives in `seat/pointer/scroll.rs`. Taken from storytold/pdfcraft vendor/winit patch (13) (storytold/pdfcraft#1569). No upstream winit PR yet. Co-authored-by: Brandon Thomas <echelon@gmail.com>
22 lines
952 B
Rust
22 lines
952 B
Rust
//! PdfCraft patch (13): Wayland scroll-phase policy, shared with the desktop regression tests.
|
|
|
|
use wayland_client::protocol::wl_pointer::AxisSource;
|
|
|
|
use crate::event::TouchPhase;
|
|
|
|
pub(crate) fn phase(previous: TouchPhase, source: Option<AxisSource>, has_discrete_scroll: bool, stopped: bool) -> TouchPhase {
|
|
// Wayland does not guarantee axis_stop for these sources. A pixel-only wheel must
|
|
// not start a finger gesture: consumers would retain its modifiers indefinitely.
|
|
// https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_pointer-event-axis_source
|
|
if stopped {
|
|
TouchPhase::Ended
|
|
} else if has_discrete_scroll || matches!(source, Some(AxisSource::Wheel | AxisSource::WheelTilt | AxisSource::Continuous)) {
|
|
TouchPhase::Moved
|
|
} else {
|
|
match previous {
|
|
TouchPhase::Started | TouchPhase::Moved => TouchPhase::Moved,
|
|
_ => TouchPhase::Started,
|
|
}
|
|
}
|
|
}
|