Files
zed/crates/gpui_linux
Anthony Eidandzed-zippy[bot] e39fb7c2e0 gpui: Rename ScrollWheelEvent to ScrollEvent and add trackpad scrolling on iOS (#65805)
Scrolling in GPUI comes from mouse wheels and trackpads reported by the
OS, and from touch pans that GPUI recognizes itself. All of them arrived
as `ScrollWheelEvent`, and handlers had no way to tell a finger pan from
anything else.

## API change

- `ScrollWheelEvent` → `ScrollEvent`, with a new `source: ScrollSource`
field.
- `ScrollSource` has two variants:
- `Pointer` (the default): a scroll the platform reported from a mouse
wheel or trackpad. `ScrollDelta::precise()` still tells continuous
devices apart from wheel notches.
- `Touch`: a finger pan recognized by GPUI, including its synthesized
momentum.
- `on_scroll_wheel` → `on_scroll`.
- `PlatformInput::ScrollWheel` → `PlatformInput::Scroll`.

### Compatibility

Existing app code keeps compiling: `ScrollWheelEvent` and
`on_scroll_wheel` remain as deprecated aliases. Two things still need
changes:
- Platform backends must switch to `PlatformInput::Scroll`. Rust can't
alias an enum variant.
- `ScrollEvent` literals that list every field must add `source`.
Literals using `..Default::default()` get `ScrollSource::Pointer`.

## Trackpad and mouse-wheel scrolling on iOS

`gpui_ios` previously handled only raw touches, so trackpads and mice on
iPad couldn't scroll. The backend now adds a `UIPanGestureRecognizer` to
the Metal view that accepts all scroll types and sends each step as a
`ScrollEvent` with the pointer position and modifiers.

The recognizer has an empty `allowedTouchTypes` and
`cancelsTouchesInView = false`. That way it never claims finger touches,
which keep going to `touchesBegan` and GPUI's touch recognizer.

UIKit ends these gestures when the fingers lift and leaves momentum to
the app. So for now a trackpad scroll on iOS stops when the fingers
lift, without the post-release glide that native views have.

## Verification

Done on Linux:
- `cargo test -p gpui --features test-support --lib -- gestures list::
scroll`: 72 passed.
- `./script/clippy -p gpui -p gpui_linux`: clean.
- `cargo clippy` for `gpui_ios` (`aarch64-apple-ios`) and `gpui_macos`
(`aarch64-apple-darwin`): clean.
- `cargo check -p gpui_web` (`wasm32-unknown-unknown`): clean.
- A temporary downstream-style test confirmed that code using
`ScrollWheelEvent` and `.on_scroll_wheel(...)` still compiles and
receives scrolls.

Not verified:
- **Windows:** wasn't type-checked locally, because `gpui`'s build
script needs the Windows resource compiler. CI covers it.
- **iOS behavior:** trackpad and wheel scrolling on an iPad hasn't been
tried. Specifically unconfirmed: scroll direction under natural
scrolling, and that finger pans don't also trigger the scroll
recognizer.

Release Notes:

- [GPUI] Renamed `ScrollWheelEvent` to `ScrollEvent` and
`on_scroll_wheel` to `on_scroll` (old names remain as deprecated
aliases), added `ScrollEvent::source` to distinguish pointer scrolling
from GPUI-recognized touch pans, and added trackpad and mouse-wheel
scrolling on iOS

---------

Co-authored-by: zed-zippy[bot] <234243425+zed-zippy[bot]@users.noreply.github.com>
2026-10-20 01:13:50 +00:00
..