Skip to content

PdfCraft: An open-source PDF reader and editor written by scratch in pure Rust

M3: touchpad swipes glide on after the fingers lift on Wayland (#531) (#1909)

mlkonrad6882275ee5d1
diff --git a/ROADMAP.md b/ROADMAP.md
index ed84b6ab4..e34a00af6 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -159,6 +159,7 @@ Ranked; detail and the full milestone table in [docs/roadmap.md](docs/roadmap.md
- **2026-10-12 (M3, page-label navigation):** The page box displays logical labels and keeps the current page when its unchanged value is submitted, including duplicate labels. Editable-control regressions also cover numeric fallback, invalid input, active typing and focused same-document replacement with changed labels or fewer pages. Clean file-watcher reload preserves the chosen scrolling mode, preventing a Single Page reader from jumping to page 1 during replacement. Estimates unchanged.
- **2026-10-13 (community, M2/M6, form-heavy documents):** An image whose pixels hold at most 16 bits of samples (an 8-bit Separation or DeviceN spot-colour image, a 1-4-bit gray or indexed one) is converted once per possible pixel value instead of once per pixel (vendored hayro-interpret patch 28). A fillable character sheet whose 3304 × 4105 DeviceN background ran a PostScript tint transform per pixel drew each page in 3.8 s and 430 MB, on opening and again after every field was filled; it now draws in 0.11 s and 100 MB, pixel for pixel the same. The inspector places widgets without `/P` in one pass over the pages (a form of 8,000 such fields opened in 1.17 s), and the Fields panel pairs its rows with the form through one map a frame and draws only the rows in view (8,000 fields: about 15× less CPU a frame with the panel open). Regressions fail before each fix.
- **2026-10-13 (M3, native-opening candidate):** Chosen tools survive preparation, conversion and password retries; startup intake waits for pending preparation. Regression tests cover completion, cancellation and document identity. Estimates unchanged.
+- **2026-10-13 (community, M3, #531 touchpad momentum):** On Wayland a two-finger swipe keeps gliding after the fingers lift and slows to a stop, measured from the gesture's last 0.1 s and decaying with a 0.35 s time constant through the #759 1:1 path. Any wheel input, click, key, zoom or edge ends it (fingers resting on the touchpad don't yet: the vendored winit binds no Wayland hold gestures); single-page paging, macOS (which sends its own momentum), the web, and Animation effects Off never glide. Unit tests for the physics and two headless view tests. Estimates unchanged.
- **2026-10-12 (M10, Windows printing without PowerShell, #1107):** craft-print now prints on Windows in-process: printers from EnumPrinters/GetDefaultPrinter, jobs drawn as vectors by Windows.Data.Pdf into the XPS print API with a driver-validated PrintTicket (exact paper, orientation, no scaling), so printing works where App Control for Business or AppLocker run PowerShell in Constrained Language Mode. Portrait and landscape sheets still print as one job (turned with /Rotate); a sheet size the driver lacks is refused rather than shrunk. Pins craft-libs f03ec27 (craft-libs#28); deny.toml allows the storytold/winprint.rs fork and adds a webpki-root-certs licence exception and a RUSTSEC-2024-0370 ignore for winprint's build-dependencies. An earlier craft-print revision was checked in Windows Sandbox under enforced WDAC: printers listed, CLI and desktop jobs spooled, and no powershell.exe in the 4688 audit. The final pinned revision passed craft-libs Windows CI, including a real paused-queue job; that Sandbox run has not been repeated. Estimates unchanged.
- **2026-10-12 (M4, #1310, #1311, #1312):** Undo back to the opened file left it marked unsaved, so recovery and close treated unchanged work as dirty. After a save, Revert followed the restored snapshot's older base and the next save dropped the latest saved revision. The last saved file is remembered on its own: undo and redo are clean only when they land on it, Revert opens it, and a later save appends to it. Estimates unchanged.
- **2026-10-12 (M13, CLI robustness scans):** `pdfcraft-cli check` visits a directory once even when input roots overlap or directory symlinks lead back into the tree. PDFs reached through file symlinks remain accepted. Three real CLI regressions cover overlapping roots, a directory cycle and directory/file aliases. Estimates unchanged.
diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs
index f2f60a742..fc4366ff0 100644
--- a/crates/ui-egui/src/canvas.rs
+++ b/crates/ui-egui/src/canvas.rs
@@ -396,6 +396,8 @@ pub struct DocView {
/// (#759). The window outlasts a single frame so egui's internal easing tail is suppressed as
/// it decays, instead of adding on top of the 1:1 motion.
precise_scroll_until: f64,
+ /// Touchpad momentum after the fingers lift (#531).
+ fling: crate::fling::Fling,
pub(crate) auto_scroll: crate::autoscroll::AutoScroll,
/// Pages selected in the organize grid or the Pages panel (0-based). Empty means "the current page".
pub selected: BTreeSet<usize>,
@@ -650,6 +652,7 @@ impl DocView {
shown: false,
wheel: Default::default(),
precise_scroll_until: 0.0,
+ fling: Default::default(),
auto_scroll: Default::default(),
selected: BTreeSet::new(),
select_anchor: None,
@@ -2278,6 +2281,22 @@ pub fn document_area(app: &mut PdfCraftApp, index: usize, ui: &mut egui::Ui) {
} else {
precise_scroll = Vec2::ZERO;
}
+ // Touchpad momentum (#531): a swipe over the page lifted at speed glides on and slows to a
+ // stop, through the same un-eased path. Never while the pager owns the wheel, a gesture or
+ // dialog has the input, or animations are off; any click, key, zoom or other scrolling ends it.
+ // Asked of the preference, not of egui's animation time, which test harnesses zero.
+ let animates = app.animation_effects.animates(app.motion.reduced);
+ let may_glide = !single_paging && !middle_gesture && navigation_enabled && unobstructed && animates;
+ let over_page = ui.rect_contains_pointer(avail);
+ ui.input(|i| view.fling.read(&i.events, now, may_glide && over_page));
+ let interrupted = ui.input(|i| i.pointer.any_pressed() || i.events.iter().any(|e| matches!(e, egui::Event::Key { pressed: true, .. })));
+ if !may_glide || interrupted || key_scroll != 0.0 || auto_delta != Vec2::ZERO || zoom_delta != 1.0 {
+ view.fling.stop();
+ }
+ let glide = view.fling.step(now);
+ if view.fling.gliding() {
+ ui.ctx().request_repaint();
+ }
let visible_pages: Vec<usize> = if view.continuous { (0..rects.len()).collect() } else { row.clone() };
let (y_shift, content_h) = if view.continuous {
(0.0, rects.iter().map(|r| r.bottom()).reduce(f32::max).map(|bottom| bottom + MARGIN).unwrap_or(0.0))
@@ -2434,9 +2453,10 @@ pub fn document_area(app: &mut PdfCraftApp, index: usize, ui: &mut egui::Ui) {
// Only interactions pause; the document must keep its original colours.
ui.set_opacity(opacity);
}
- // Middle-button auto-scroll, the keyboard and precise touchpad input (#759); positive y
- // moves the content down. All three scroll without easing, unlike egui's wheel default.
- let delta = auto_delta - vec2(0.0, key_scroll) + precise_scroll;
+ // Middle-button auto-scroll, the keyboard, precise touchpad input (#759) and its glide
+ // (#531); positive y moves the content down. All scroll without easing, unlike egui's
+ // wheel default.
+ let delta = auto_delta - vec2(0.0, key_scroll) + precise_scroll + glide;
if delta != Vec2::ZERO {
ui.scroll_with_delta_animation(delta, egui::style::ScrollAnimation::none());
}
@@ -3227,6 +3247,9 @@ pub fn document_area(app: &mut PdfCraftApp, index: usize, ui: &mut egui::Ui) {
view.pan_hold_until = now_settle + 0.25;
ui.ctx().request_repaint_after(std::time::Duration::from_millis(280));
}
+ if glide != Vec2::ZERO {
+ view.fling.moved((scroll_offset - view.last_scroll).length() > 0.01);
+ }
view.last_scroll = scroll_offset;
let pan_held = now_settle < view.pan_hold_until;
let (mut wanted, visible_now) = out.inner;
diff --git a/crates/ui-egui/src/fling.rs b/crates/ui-egui/src/fling.rs
new file mode 100644
index 000000000..cce004ce5
--- /dev/null
+++ b/crates/ui-egui/src/fling.rs
@@ -0,0 +1,276 @@
+//! Touchpad momentum (#531): a two-finger swipe keeps gliding after the fingers lift, and slows
+//! to a stop.
+//!
+//! Wayland compositors leave momentum to the client. libinput reports the swipe as pixel deltas
+//! (`MouseWheelUnit::Point`) and the lift as an axis stop, which winit passes on as
+//! `TouchPhase::End`; GTK and Firefox glide on from there, and so does the page view.
+//!
+//! macOS sends its own momentum as a second `Start`…`End`, so gliding there would glide twice,
+//! and the web has no touch phases: [`Fling::enabled`] is off on both. Windows and X11 report no
+//! touch phases through winit either, so no `End` ever starts a glide there.
+
+use egui::{Event, MouseWheelUnit, TouchPhase, Vec2};
+
+/// Seconds of the gesture the lift speed is measured over.
+const WINDOW: f64 = 0.1;
+/// A lift this long after the last motion is a finger that stopped first: no glide.
+const STILL: f64 = 0.05;
+/// The glide slows by `e` every this many seconds; it travels the lift speed times this.
+const TAU: f32 = 0.35;
+/// Below this speed (points per second) a lift doesn't glide, and a glide stops.
+const START_SPEED: f32 = 150.0;
+const STOP_SPEED: f32 = 10.0;
+/// Fastest glide, in points per second: a flick the system measured over a hiccup can't throw
+/// the document to its end.
+const MAX_SPEED: f32 = 8000.0;
+/// A pass this long after the last one (the view was hidden, the app stalled) ends a glide.
+const STALE: f64 = 0.1;
+
+pub(crate) struct Fling {
+ /// Whether a lift glides on this platform (see the module docs).
+ pub(crate) enabled: bool,
+ /// The gesture in progress: when each pass's motion arrived, and how far it went.
+ samples: Vec<(f64, Vec2)>,
+ /// The glide's speed in points per second (positive moves the content down), or zero.
+ velocity: Vec2,
+ /// When the glide last moved.
+ at: f64,
+ /// Passes in a row the glide moved the view not at all: it is against an edge.
+ stalled: u8,
+}
+
+impl Default for Fling {
+ fn default() -> Self {
+ Self::new(!cfg!(any(target_os = "macos", target_arch = "wasm32")))
+ }
+}
+
+impl Fling {
+ pub(crate) fn new(enabled: bool) -> Self {
+ Self { enabled, samples: Vec::new(), velocity: Vec2::ZERO, at: 0.0, stalled: 0 }
+ }
+
+ pub(crate) fn gliding(&self) -> bool {
+ self.velocity != Vec2::ZERO
+ }
+
+ pub(crate) fn stop(&mut self) {
+ self.velocity = Vec2::ZERO;
+ self.stalled = 0;
+ }
+
+ /// Reads one pass's wheel events, at time `now`. Any wheel input stops a glide; a touchpad
+ /// gesture's `End` may start one. `glide` is false where the view must not glide this pass
+ /// (animations off, single-page paging, a zoom, a dialog).
+ pub(crate) fn read(&mut self, events: &[Event], now: f64, glide: bool) {
+ for event in events {
+ let Event::MouseWheel { unit, delta, phase, modifiers } = event else { continue };
+ self.stop();
+ // Zooming, a mouse wheel and sideways Shift scrolling never glide.
+ if *unit != MouseWheelUnit::Point || modifiers.command || modifiers.ctrl || modifiers.shift {
+ self.samples.clear();
+ continue;
+ }
+ match phase {
+ TouchPhase::Start => {
+ self.samples.clear();
+ self.push(now, *delta);
+ }
+ TouchPhase::Move => self.push(now, *delta),
+ TouchPhase::End => {
+ if glide && self.enabled {
+ self.velocity = self.lift_velocity(now);
+ self.at = now;
+ }
+ self.samples.clear();
+ }
+ TouchPhase::Cancel => self.samples.clear(),
+ }
+ }
+ }
+
+ fn push(&mut self, now: f64, delta: Vec2) {
+ if !(delta.x.is_finite() && delta.y.is_finite()) {
+ return;
+ }
+ match self.samples.last_mut() {
+ // Several events in one pass are one sample: they share its time.
+ Some((at, d)) if *at == now => *d += delta,
+ _ => self.samples.push((now, delta)),
+ }
+ self.samples.retain(|(at, _)| now - at <= WINDOW);
+ }
+
+ /// The finger's speed as it lifted at `now`, or zero when it should not glide.
+ fn lift_velocity(&self, now: f64) -> Vec2 {
+ let recent: Vec<&(f64, Vec2)> = self.samples.iter().filter(|(at, _)| now - at <= WINDOW).collect();
+ let (Some(first), Some(last)) = (recent.first(), recent.last()) else { return Vec2::ZERO };
+ let span = (last.0 - first.0) as f32;
+ if recent.len() < 2 || span <= 0.0 || now - last.0 > STILL {
+ return Vec2::ZERO;
+ }
+ // Each sample is the motion since the pass before it, so the first one's motion
+ // happened before the span starts.
+ let moved = recent.iter().skip(1).fold(Vec2::ZERO, |sum, (_, d)| sum + *d);
+ let v = moved / span;
+ if !(v.x.is_finite() && v.y.is_finite()) || v.length() < START_SPEED {
+ return Vec2::ZERO;
+ }
+ if v.length() > MAX_SPEED { v * (MAX_SPEED / v.length()) } else { v }
+ }
+
+ /// How far the glide moves the view in the pass at `now` (zero when not gliding), as the
+ /// exact distance a speed decaying with [`TAU`] covers since the last pass.
+ pub(crate) fn step(&mut self, now: f64) -> Vec2 {
+ if !self.gliding() {
+ return Vec2::ZERO;
+ }
+ let dt = now - self.at;
+ if !(0.0..=STALE).contains(&dt) {
+ self.stop();
+ return Vec2::ZERO;
+ }
+ self.at = now;
+ let decay = (-(dt as f32) / TAU).exp();
+ let moved = self.velocity * TAU * (1.0 - decay);
+ self.velocity *= decay;
+ if self.velocity.length() < STOP_SPEED {
+ self.stop();
+ }
+ moved
+ }
+
+ /// After a pass the glide moved the view in: whether the offset changed. Two passes that
+ /// didn't move it mean an edge, and the glide ends there.
+ pub(crate) fn moved(&mut self, moved: bool) {
+ if moved {
+ self.stalled = 0;
+ } else {
+ self.stalled = self.stalled.saturating_add(1);
+ if self.stalled >= 2 {
+ self.stop();
+ }
+ }
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use egui::{Modifiers, vec2};
+
+ fn wheel(dy: f32, phase: TouchPhase) -> Event {
+ Event::MouseWheel { unit: MouseWheelUnit::Point, delta: vec2(0.0, dy), phase, modifiers: Modifiers::NONE }
+ }
+
+ /// A swipe of `moves` passes of `dy` each, 60 per second, lifted the pass after the last.
+ fn swipe(fling: &mut Fling, dy: f32, moves: usize) -> f64 {
+ let dt = 1.0 / 60.0;
+ let mut now = 0.0;
+ fling.read(&[wheel(dy, TouchPhase::Start)], now, true);
+ for _ in 0..moves {
+ now += dt;
+ fling.read(&[wheel(dy, TouchPhase::Move)], now, true);
+ }
+ now += dt;
+ fling.read(&[wheel(0.0, TouchPhase::End)], now, true);
+ now
+ }
+
+ #[test]
+ fn a_flick_glides_on_at_its_lift_speed_and_stops() {
+ let mut fling = Fling::new(true);
+ let mut now = swipe(&mut fling, -25.0, 6);
+ assert!(fling.gliding());
+ // 25 points a pass at 60 passes a second.
+ assert!((fling.velocity.y + 1500.0).abs() < 1.0, "{:?}", fling.velocity);
+ let mut travelled = 0.0;
+ let mut passes = 0;
+ while fling.gliding() {
+ now += 1.0 / 60.0;
+ let d = fling.step(now);
+ assert!(d.y <= 0.0 && d.x == 0.0, "keeps the swipe's direction: {d:?}");
+ travelled += d.y;
+ passes += 1;
+ assert!(passes < 600, "the glide ends");
+ }
+ // Speed × TAU, less the tail under STOP_SPEED.
+ assert!((-travelled - 1500.0 * TAU).abs() < 10.0, "travelled {travelled}");
+ assert_eq!(fling.step(now + 1.0 / 60.0), Vec2::ZERO);
+ }
+
+ #[test]
+ fn a_slow_drag_or_a_pause_before_lifting_does_not_glide() {
+ let mut fling = Fling::new(true);
+ swipe(&mut fling, -1.0, 6);
+ assert!(!fling.gliding(), "60 points a second is below the start speed");
+
+ let mut fling = Fling::new(true);
+ let dt = 1.0 / 60.0;
+ fling.read(&[wheel(-25.0, TouchPhase::Start)], 0.0, true);
+ fling.read(&[wheel(-25.0, TouchPhase::Move)], dt, true);
+ fling.read(&[wheel(0.0, TouchPhase::End)], dt + 0.2, true);
+ assert!(!fling.gliding(), "the finger rested before it lifted");
+ }
+
+ #[test]
+ fn new_input_stops_a_glide() {
+ let mut fling = Fling::new(true);
+ let now = swipe(&mut fling, -25.0, 6);
+ fling.read(&[wheel(-2.0, TouchPhase::Start)], now + 0.1, true);
+ assert!(!fling.gliding(), "fingers back on the touchpad");
+
+ let mut fling = Fling::new(true);
+ let now = swipe(&mut fling, -25.0, 6);
+ let notch = Event::MouseWheel { unit: MouseWheelUnit::Line, delta: vec2(0.0, -1.0), phase: TouchPhase::Move, modifiers: Modifiers::NONE };
+ fling.read(&[notch], now + 0.1, true);
+ assert!(!fling.gliding(), "a wheel notch");
+ }
+
+ #[test]
+ fn no_glide_where_it_is_off_or_not_wanted() {
+ let mut off = Fling::new(false);
+ swipe(&mut off, -25.0, 6);
+ assert!(!off.gliding(), "macOS and the web glide by themselves or not at all");
+
+ let mut fling = Fling::new(true);
+ let dt = 1.0 / 60.0;
+ fling.read(&[wheel(-25.0, TouchPhase::Start)], 0.0, true);
+ fling.read(&[wheel(-25.0, TouchPhase::Move)], dt, true);
+ fling.read(&[wheel(-25.0, TouchPhase::Move)], 2.0 * dt, true);
+ fling.read(&[wheel(0.0, TouchPhase::End)], 3.0 * dt, false);
+ assert!(!fling.gliding(), "animations off, paging or a dialog");
+
+ let mut zoom = Fling::new(true);
+ let ctrl = |phase| Event::MouseWheel { unit: MouseWheelUnit::Point, delta: vec2(0.0, -25.0), phase, modifiers: Modifiers::COMMAND };
+ zoom.read(&[ctrl(TouchPhase::Start)], 0.0, true);
+ zoom.read(&[ctrl(TouchPhase::Move)], dt, true);
+ zoom.read(&[ctrl(TouchPhase::Move)], 2.0 * dt, true);
+ zoom.read(&[ctrl(TouchPhase::End)], 3.0 * dt, true);
+ assert!(!zoom.gliding(), "a pinch or ⌘/Ctrl swipe zooms");
+ }
+
+ #[test]
+ fn an_edge_a_stall_or_a_wild_speed_ends_or_caps_the_glide() {
+ let mut fling = Fling::new(true);
+ let now = swipe(&mut fling, -25.0, 6);
+ fling.step(now + 1.0 / 60.0);
+ fling.moved(false);
+ assert!(fling.gliding(), "one pass may not show the move yet");
+ fling.moved(false);
+ assert!(!fling.gliding(), "against the edge");
+
+ let mut fling = Fling::new(true);
+ let now = swipe(&mut fling, -25.0, 6);
+ assert_eq!(fling.step(now + 1.0), Vec2::ZERO, "a second-long gap (the tab was hidden)");
+ assert!(!fling.gliding());
+
+ let mut fling = Fling::new(true);
+ swipe(&mut fling, -5000.0, 6);
+ assert!((fling.velocity.length() - MAX_SPEED).abs() < 1.0, "{:?}", fling.velocity);
+
+ let mut fling = Fling::new(true);
+ swipe(&mut fling, f32::NAN, 6);
+ assert!(!fling.gliding(), "a speed that isn't a number");
+ }
+}
diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs
index aef83403d..8aacc7eea 100644
--- a/crates/ui-egui/src/lib.rs
+++ b/crates/ui-egui/src/lib.rs
@@ -78,6 +78,7 @@ mod editing;
pub mod file_watch;
mod files;
pub mod fill_sign;
+mod fling;
pub mod folders_ui;
pub mod forms_ui;
mod home;
diff --git a/crates/ui-egui/tests/view.rs b/crates/ui-egui/tests/view.rs
index a48a86c07..1f27a7314 100644
--- a/crates/ui-egui/tests/view.rs
+++ b/crates/ui-egui/tests/view.rs
@@ -256,6 +256,86 @@ fn precise_touchpad_wheel_scrolls_one_to_one() {
assert!(drift.abs() < 2.0, "no easing tail after the swipe: drifted {drift}");
}
+/// Steps `frames` frames and returns how far the document scrolled down over them, from the
+/// pages on screen in each pair of consecutive frames (a page can leave the screen on the way).
+fn scroll_over(h: &mut Harness<'static, PdfCraftApp>, frames: usize) -> f32 {
+ let tops = |h: &Harness<'static, PdfCraftApp>| (0..3).map(|p| rect(h, p).map(|r| r.min.y)).collect::<Vec<_>>();
+ let mut moved = 0.0;
+ for _ in 0..frames {
+ let before = tops(h);
+ h.step();
+ let after = tops(h);
+ let step = before.iter().zip(&after).find_map(|(b, a)| Some(b.as_ref()? - a.as_ref()?));
+ moved += step.expect("a page stays on screen from one frame to the next");
+ }
+ moved
+}
+
+/// A two-finger swipe down the page, 25 points a frame for six frames, lifted the frame after
+/// (the axis stop Wayland sends), at 300 % so the document is long enough to glide in: how far
+/// it scrolled by the frame after the lift (the page is drawn a frame behind its scroll).
+fn swipe_and_lift(h: &mut Harness<'static, PdfCraftApp>) -> f32 {
+ let at = h.state().views[0].viewport_rect().center();
+ h.hover_at(at);
+ h.run_steps(2);
+ h.event(wheel(MouseWheelUnit::Point, -25.0, TouchPhase::Start));
+ let mut moved = scroll_over(h, 1);
+ for _ in 0..6 {
+ h.event(wheel(MouseWheelUnit::Point, -25.0, TouchPhase::Move));
+ moved += scroll_over(h, 1);
+ }
+ h.event(wheel(MouseWheelUnit::Point, 0.0, TouchPhase::End));
+ moved + scroll_over(h, 2)
+}
+
+/// The touchpad glide is Wayland's: macOS sends its own momentum and the web none (#531).
+#[cfg(not(target_os = "macos"))]
+#[test]
+fn touchpad_swipe_glides_on_after_the_fingers_lift_and_stops() {
+ let mut h = harness_stepping(1.0 / 60.0, &[("layout", "continuous"), ("zoom", "300")]);
+ let swiped = swipe_and_lift(&mut h);
+ // The seven 25-point motions, 1:1 (#759).
+ assert!(swiped >= 174.0, "the swipe scrolls 1:1: moved {swiped}");
+ // 1500 points a second at the lift: about 190 points over the next 10 frames.
+ let glided = scroll_over(&mut h, 10);
+ assert!(glided > 100.0, "the page glides on after the lift: moved {glided} more");
+ let rest = scroll_over(&mut h, 180);
+ let drift = scroll_over(&mut h, 20);
+ assert!(drift.abs() < 0.5, "the glide slows to a stop: still drifting {drift}");
+ let total = swiped - 175.0 + glided + rest;
+ assert!(total > 400.0 && total < 600.0, "about the lift speed × 0.35 s: glided {total}");
+}
+
+#[cfg(not(target_os = "macos"))]
+#[test]
+fn touching_the_touchpad_again_or_turning_animations_off_stops_the_glide() {
+ let mut h = harness_stepping(1.0 / 60.0, &[("layout", "continuous"), ("zoom", "300")]);
+ swipe_and_lift(&mut h);
+ assert!(scroll_over(&mut h, 3) > 30.0, "gliding");
+ h.event(wheel(MouseWheelUnit::Point, 0.0, TouchPhase::Start));
+ scroll_over(&mut h, 2);
+ let drift = scroll_over(&mut h, 20);
+ assert!(drift.abs() < 0.5, "fingers back down catch the page: drifted {drift}");
+
+ // A click (a pressed touchpad, or a tap with tap-to-click) catches it too.
+ let mut h = harness_stepping(1.0 / 60.0, &[("layout", "continuous"), ("zoom", "300")]);
+ swipe_and_lift(&mut h);
+ assert!(scroll_over(&mut h, 3) > 30.0, "gliding");
+ let at = h.state().views[0].viewport_rect().center();
+ h.event(egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed: true, modifiers: Modifiers::NONE });
+ scroll_over(&mut h, 2);
+ let drift = scroll_over(&mut h, 20);
+ assert!(drift.abs() < 0.5, "a click catches the page: drifted {drift}");
+
+ // Animation effects off: the page stops with the fingers, as before #531.
+ let mut h = harness_stepping(1.0 / 60.0, &[("layout", "continuous"), ("zoom", "300")]);
+ h.state_mut().set_option("animation_effects", "off").unwrap();
+ let swiped = swipe_and_lift(&mut h);
+ assert!((swiped - 175.0).abs() < 1.0, "the swipe still scrolls 1:1: moved {swiped}");
+ let drift = scroll_over(&mut h, 20);
+ assert!(drift.abs() < 0.5, "no glide with animations off: drifted {drift}");
+}
+
/// The 40 frames from one wheel notch on, with the system asking for no animations (Windows'
/// Animation effects turned off) or not, and Preferences ▸ Animation effects as given: how far
/// page 1 has moved up in each frame, or with ⌘/Ctrl held, the view's zoom.
diff --git a/parity/acrobat-features.toml b/parity/acrobat-features.toml
index ad337a87e..0a3816046 100644
--- a/parity/acrobat-features.toml
+++ b/parity/acrobat-features.toml
@@ -854,8 +854,8 @@ milestone = "M3"
status = "shipped"
commands = ["view.continuous"]
tools = []
-evidence = ["crates/ui-egui/tests/view.rs::continuous_layout_stacks_pages_vertically", "crates/ui-egui/tests/view.rs::page_display_commands_switch_layouts", "crates/ui-egui/tests/view.rs::default_page_display_is_used_for_new_documents", "crates/ui-egui/src/canvas.rs::fit_page_and_height_hold_still_while_mixed_page_sizes_scroll_past"]
-notes = "the default for PDFs that don't ask for a layout (Preferences ▸ Default page display); pages stack with no snapping. Fit page and Fit height fit the largest page, so the zoom holds still across mixed page sizes"
+evidence = ["crates/ui-egui/tests/view.rs::continuous_layout_stacks_pages_vertically", "crates/ui-egui/tests/view.rs::page_display_commands_switch_layouts", "crates/ui-egui/tests/view.rs::default_page_display_is_used_for_new_documents", "crates/ui-egui/src/canvas.rs::fit_page_and_height_hold_still_while_mixed_page_sizes_scroll_past", "crates/ui-egui/tests/view.rs::touchpad_swipe_glides_on_after_the_fingers_lift_and_stops", "crates/ui-egui/tests/view.rs::touching_the_touchpad_again_or_turning_animations_off_stops_the_glide"]
+notes = "the default for PDFs that don't ask for a layout (Preferences ▸ Default page display); pages stack with no snapping. Fit page and Fit height fit the largest page, so the zoom holds still across mixed page sizes. A touchpad swipe glides on after the fingers lift on Wayland (#531; macOS glides by itself; Windows and X11 report no lift through winit), unless Animation effects is off; a click, key, zoom or new scroll catches it. Not yet: fingers resting on the touchpad don't catch it (needs Wayland hold gestures, which the vendored winit doesn't bind)"
[[feature]]
id = "view.layout-single-page"