Skip to content

Middle-button pan follows the frame's pointer events, so a drag isn't lost on slow frames - #1132

Open
marcoarnulfo wants to merge 1 commit into
storytold:mainfrom
marcoarnulfo:fix/middle-pan
Open

marcoarnulfo wants to merge 1 commit into
storytold:mainfrom
marcoarnulfo:fix/middle-pan

Conversation

@marcoarnulfo

Copy link
Copy Markdown
Contributor

Fixes #1131.

The middle-button pan only looked at the button state and the pointer position at the end of each frame. On a heavy drawing frames are slow, and eframe hands over a whole drag in one go: when the release lands in the same frame as the moves, the button already reads as up when the frame ends and all the movement is dropped. The wheel sums its raw events (wheel_zoom_points, #660), so it always zooms, which is the "pan doesn't work, only scroll-zoom does" asymmetry in the report, and why it depends on the file and on the zoom level (zooming out on a big drawing makes frames slower). The pan now walks the frame's pointer events in order, like the wheel: a middle press over the drawing starts it (same inside check as before, so a press over a floating panel still doesn't pan), each move while it is on adds its delta, and the release ends it. At normal frame rates the result is the same as before, since the moves add up to the end-of-frame position.

This makes the pan correct on heavy drawings, not smooth: each slow frame still lands as one jump. The frame time itself is #1071, with #997 and #1012 working on it.

I also dropped the i.focused check from the pan (added with docking in e09fb50, without a test of its own): the wheel zooms in an unfocused window, and a middle click doesn't focus the window on macOS, so the pan silently didn't start there. A pan in progress still ends when the window loses focus. Happy to switch back if the check was there for a reason I missed.

The change stays inside the pan block of canvas.rs, since #1061 (splitting canvas.rs into modules), #1059 and #1012 touch the same file; happy to rebase onto any of them if they land first.

Validation:

  • middle_pan_slow_frames::a_middle_drag_that_ends_within_one_slow_frame_still_pans: fails on main (View { center: (100, 70), height: 220 } unchanged after a 100 px drag), passes here
  • middle_pan_slow_frames::a_whole_middle_drag_within_one_slow_frame_still_pans (press, moves and release in one frame): fails on main the same way, passes here
  • cargo test -p cadcraft-ui-egui --test middle_pan_slow_frames --test docking_workflows --test mspace_viewport_view --test rapid_clicks --test system_cursor
  • cargo clippy -p cadcraft-ui-egui --all-targets -- -D warnings, cargo fmt --all -- --check
  • (macOS, Apple silicon)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistent middle-mouse pan behavior across files: sometimes works, sometimes not, sometimes stops after zooming

1 participant