Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

gpui: Rename `ScrollWheelEvent` to `ScrollEvent` and add trackpad scrolling on iOS (#65805)

Anthony Eide39fb7c2e056
diff --git a/Cargo.toml b/Cargo.toml
index 7c28a25849b..25ed86481ba 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -710,8 +710,11 @@ objc2-ui-kit = { version = "0.3.2", default-features = false, features = [
"objc2-core-foundation",
"NSText",
"UIApplication",
+ "UICommand",
"UIEvent",
"UIGeometry",
+ "UIGestureRecognizer",
+ "UIPanGestureRecognizer",
"UIInterface",
"UIOpenURLContext",
"UIPasteboard",
diff --git a/crates/agent_ui/src/conversation_view.rs b/crates/agent_ui/src/conversation_view.rs
index ee321378226..a0b7d946c6d 100644
--- a/crates/agent_ui/src/conversation_view.rs
+++ b/crates/agent_ui/src/conversation_view.rs
@@ -6661,11 +6661,12 @@ pub(crate) mod tests {
.expect("notices received before mounting the view should render");
let max_height = cx.update(|window, _| rems_from_px(192_f32).to_pixels(window.rem_size()));
assert!(notices.size.height <= max_height);
- cx.simulate_event(gpui::ScrollWheelEvent {
+ cx.simulate_event(gpui::ScrollEvent {
position: notices.center(),
delta: gpui::ScrollDelta::Pixels(gpui::point(px(0.), px(-10_000.))),
modifiers: gpui::Modifiers::default(),
touch_phase: gpui::TouchPhase::Moved,
+ source: gpui::ScrollSource::Pointer,
});
cx.run_until_parked();
diff --git a/crates/debugger_ui/src/session/running/memory_view.rs b/crates/debugger_ui/src/session/running/memory_view.rs
index 90fd5964d00..4b3407b93a5 100644
--- a/crates/debugger_ui/src/session/running/memory_view.rs
+++ b/crates/debugger_ui/src/session/running/memory_view.rs
@@ -10,7 +10,7 @@ use std::{
use editor::{Editor, EditorElement, EditorStyle};
use gpui::{
Action, Along, AppContext, Axis, DismissEvent, DragMoveEvent, Empty, Entity, FocusHandle,
- Focusable, ListHorizontalSizingBehavior, MouseButton, Point, ScrollStrategy, ScrollWheelEvent,
+ Focusable, ListHorizontalSizingBehavior, MouseButton, Point, ScrollEvent, ScrollStrategy,
Subscription, Task, TextStyle, UniformList, UniformListScrollHandle, WeakEntity, actions,
anchored, deferred, uniform_list,
};
@@ -231,7 +231,7 @@ impl MemoryView {
)
.track_scroll(&view_state.scroll_handle)
.with_horizontal_sizing_behavior(ListHorizontalSizingBehavior::Unconstrained)
- .on_scroll_wheel(cx.listener(|this, evt: &ScrollWheelEvent, window, _| {
+ .on_scroll(cx.listener(|this, evt: &ScrollEvent, window, _| {
let mut view_state = this.view_state();
let delta = evt.delta.pixel_delta(window.line_height());
let current_offset = view_state.scroll_handle.offset();
diff --git a/crates/debugger_ui/src/tests/hover_values.rs b/crates/debugger_ui/src/tests/hover_values.rs
index 0401e407c93..5a9b2d9c2ba 100644
--- a/crates/debugger_ui/src/tests/hover_values.rs
+++ b/crates/debugger_ui/src/tests/hover_values.rs
@@ -969,11 +969,12 @@ async fn test_hover_values_keyboard_selection_scrolls_into_view(
gpui::point(gpui::px(0.), gpui::px(10.)),
] {
let before = scroll_handle.offset();
- editor_cx.simulate_event(gpui::ScrollWheelEvent {
+ editor_cx.simulate_event(gpui::ScrollEvent {
position,
delta: gpui::ScrollDelta::Pixels(delta),
modifiers: Modifiers::none(),
touch_phase: gpui::TouchPhase::Moved,
+ source: gpui::ScrollSource::Pointer,
});
editor_cx.run_until_parked();
assert_eq!(scroll_handle.bounds(), viewport);
diff --git a/crates/editor/src/element/mouse.rs b/crates/editor/src/element/mouse.rs
index 1d8bb5dc65a..0258d696f6b 100644
--- a/crates/editor/src/element/mouse.rs
+++ b/crates/editor/src/element/mouse.rs
@@ -6,8 +6,8 @@ use feature_flags::{DiffReviewFeatureFlag, FeatureFlagAppExt as _};
use gpui::{
AnyElement, App, AvailableSpace, ClickEvent, Context, DispatchPhase, Element, MouseButton,
MouseClickEvent, MouseDownEvent, MouseMoveEvent, MousePressureEvent, MouseUpEvent,
- ParentElement, Pixels, PressureStage, ScrollDelta, ScrollWheelEvent, Window, anchored,
- deferred, point, px,
+ ParentElement, Pixels, PressureStage, ScrollDelta, ScrollEvent, Window, anchored, deferred,
+ point, px,
};
use multi_buffer::MultiBufferRow;
use project::DisableAiSettings;
@@ -502,7 +502,7 @@ impl EditorElement {
.fast_scroll_sensitivity
.max(0.01);
- move |event: &ScrollWheelEvent, phase, window, cx| {
+ move |event: &ScrollEvent, phase, window, cx| {
if phase == DispatchPhase::Bubble && hitbox.should_handle_scroll(window) {
delta = delta.coalesce(event.delta);
diff --git a/crates/editor/src/hover_popover.rs b/crates/editor/src/hover_popover.rs
index 7b3c9975aff..dc9af1f11d4 100644
--- a/crates/editor/src/hover_popover.rs
+++ b/crates/editor/src/hover_popover.rs
@@ -2328,11 +2328,12 @@ mod tests {
assert!(max_offset.y > px(20.));
let other_offset = handles[1 - index].offset();
let before = handle.offset();
- editor_cx.simulate_event(gpui::ScrollWheelEvent {
+ editor_cx.simulate_event(gpui::ScrollEvent {
position: viewport.center(),
delta: gpui::ScrollDelta::Pixels(gpui::point(px(0.), px(-20.))),
modifiers: Modifiers::none(),
touch_phase: gpui::TouchPhase::Moved,
+ source: gpui::ScrollSource::Pointer,
});
editor_cx.run_until_parked();
assert_eq!(handle.offset(), before + gpui::point(px(0.), px(-20.)));
diff --git a/crates/git_ui/src/git_graph.rs b/crates/git_ui/src/git_graph.rs
index f70188fa6a8..fd44284162c 100644
--- a/crates/git_ui/src/git_graph.rs
+++ b/crates/git_ui/src/git_graph.rs
@@ -20,8 +20,8 @@ use git::{
use gpui::{
Action, Anchor, AnyElement, App, Bounds, ClickEvent, ClipboardItem, DefiniteLength,
DismissEvent, DragMoveEvent, ElementId, Empty, Entity, EventEmitter, FocusHandle, Focusable,
- Hsla, MouseButton, MouseDownEvent, PathBuilder, Pixels, Point, ScrollHandle, ScrollStrategy,
- ScrollWheelEvent, SharedString, Subscription, Task, TextRun, TextStyleRefinement,
+ Hsla, MouseButton, MouseDownEvent, PathBuilder, Pixels, Point, ScrollEvent, ScrollHandle,
+ ScrollStrategy, SharedString, Subscription, Task, TextRun, TextStyleRefinement,
UniformListScrollHandle, WeakEntity, Window, actions, anchored, deferred, point, prelude::*,
px, uniform_list,
};
@@ -4118,7 +4118,7 @@ impl GitGraph {
fn handle_graph_scroll(
&mut self,
- event: &ScrollWheelEvent,
+ event: &ScrollEvent,
window: &mut Window,
cx: &mut Context<Self>,
) {
@@ -4573,7 +4573,7 @@ impl Render for GitGraph {
.min_w_0()
.overflow_hidden()
.cursor_pointer()
- .on_scroll_wheel(
+ .on_scroll(
cx.listener(Self::handle_graph_scroll),
)
.on_mouse_move(cx.listener(
diff --git a/crates/gpui/src/app/test_app.rs b/crates/gpui/src/app/test_app.rs
index bf265fd7bff..21344da2f1f 100644
--- a/crates/gpui/src/app/test_app.rs
+++ b/crates/gpui/src/app/test_app.rs
@@ -444,13 +444,14 @@ impl<V: 'static + Render> TestAppWindow<V> {
self.simulate_mouse_up(position, button);
}
- /// Simulate a scroll event.
+ /// Simulate a precise pointer scroll, as from a trackpad.
pub fn simulate_scroll(&mut self, position: Point<Pixels>, delta: Point<Pixels>) {
- self.simulate_event(crate::ScrollWheelEvent {
+ self.simulate_event(crate::ScrollEvent {
position,
delta: crate::ScrollDelta::Pixels(delta),
modifiers: Default::default(),
touch_phase: crate::TouchPhase::Moved,
+ source: crate::ScrollSource::Pointer,
});
}
diff --git a/crates/gpui/src/app/test_context.rs b/crates/gpui/src/app/test_context.rs
index b8a120f942c..ca9b8937e27 100644
--- a/crates/gpui/src/app/test_context.rs
+++ b/crates/gpui/src/app/test_context.rs
@@ -1052,7 +1052,7 @@ impl VisualTestContext {
})
}
- /// Simulate an event from the platform, e.g. a ScrollWheelEvent
+ /// Simulate an event from the platform, e.g. a ScrollEvent
/// Make sure you've called [VisualTestContext::draw] first!
pub fn simulate_event<E: InputEvent>(&mut self, event: E) {
self.test_window(self.window)
diff --git a/crates/gpui/src/elements/anchored.rs b/crates/gpui/src/elements/anchored.rs
index 29260061bb7..9fd564516d4 100644
--- a/crates/gpui/src/elements/anchored.rs
+++ b/crates/gpui/src/elements/anchored.rs
@@ -355,12 +355,12 @@ mod tests {
window
.update(cx, |_, window, cx| {
- let event = gpui::ScrollWheelEvent {
+ let event = gpui::ScrollEvent {
position: point(px(400.), px(300.)),
delta: gpui::ScrollDelta::Pixels(point(px(0.), px(-1000.))),
..Default::default()
};
- window.dispatch_event(PlatformInput::ScrollWheel(event), cx);
+ window.dispatch_event(PlatformInput::Scroll(event), cx);
})
.unwrap();
diff --git a/crates/gpui/src/elements/div.rs b/crates/gpui/src/elements/div.rs
index 5d3b03b057b..6f2781f7643 100644
--- a/crates/gpui/src/elements/div.rs
+++ b/crates/gpui/src/elements/div.rs
@@ -23,8 +23,8 @@ use crate::{
KeyboardClickEvent, LayoutId, LongPressEvent, ModifiersChangedEvent, MouseButton,
MouseClickEvent, MouseDownEvent, MouseExitEvent, MouseMoveEvent, MousePressureEvent,
MouseUpEvent, OngoingScroll, Overflow, ParentElement, PinchEvent, Pixels, Point, Render,
- ScrollWheelEvent, SharedString, Size, Style, StyleRefinement, Styled, Task, TooltipId,
- TouchPhase, Visibility, Window, WindowControlArea, point, px, size,
+ ScrollEvent, SharedString, Size, Style, StyleRefinement, Styled, Task, TooltipId, TouchPhase,
+ Visibility, Window, WindowControlArea, point, px, size,
};
use collections::HashMap;
use gpui_util::ResultExt;
@@ -383,15 +383,12 @@ impl Interactivity {
}));
}
- /// Bind the given callback to scroll wheel events during the bubble phase.
- /// The imperative API equivalent to [`InteractiveElement::on_scroll_wheel`].
+ /// Bind the given callback to scroll events during the bubble phase.
+ /// The imperative API equivalent to [`InteractiveElement::on_scroll`].
///
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
- pub fn on_scroll_wheel(
- &mut self,
- listener: impl Fn(&ScrollWheelEvent, &mut Window, &mut App) + 'static,
- ) {
- self.scroll_wheel_listeners
+ pub fn on_scroll(&mut self, listener: impl Fn(&ScrollEvent, &mut Window, &mut App) + 'static) {
+ self.scroll_listeners
.push(Box::new(move |event, phase, hitbox, window, cx| {
if phase == DispatchPhase::Bubble && hitbox.should_handle_scroll(window) {
(listener)(event, window, cx);
@@ -399,6 +396,15 @@ impl Interactivity {
}));
}
+ /// The former name of [`Interactivity::on_scroll`].
+ #[deprecated(note = "renamed to `on_scroll`")]
+ pub fn on_scroll_wheel(
+ &mut self,
+ listener: impl Fn(&ScrollEvent, &mut Window, &mut App) + 'static,
+ ) {
+ self.on_scroll(listener);
+ }
+
/// Bind the given callback to pinch gesture events during the bubble phase.
///
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
@@ -1053,18 +1059,27 @@ pub trait InteractiveElement: Sized {
self
}
- /// Bind the given callback to scroll wheel events during the bubble phase.
- /// The fluent API equivalent to [`Interactivity::on_scroll_wheel`].
+ /// Bind the given callback to scroll events during the bubble phase.
+ /// The fluent API equivalent to [`Interactivity::on_scroll`].
///
/// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback.
- fn on_scroll_wheel(
+ fn on_scroll(
mut self,
- listener: impl Fn(&ScrollWheelEvent, &mut Window, &mut App) + 'static,
+ listener: impl Fn(&ScrollEvent, &mut Window, &mut App) + 'static,
) -> Self {
- self.interactivity().on_scroll_wheel(listener);
+ self.interactivity().on_scroll(listener);
self
}
+ /// The former name of [`InteractiveElement::on_scroll`].
+ #[deprecated(note = "renamed to `on_scroll`")]
+ fn on_scroll_wheel(
+ self,
+ listener: impl Fn(&ScrollEvent, &mut Window, &mut App) + 'static,
+ ) -> Self {
+ self.on_scroll(listener)
+ }
+
/// Bind the given callback to pinch gesture events during the bubble phase.
/// The fluent API equivalent to [`Interactivity::on_pinch`].
///
@@ -1728,8 +1743,8 @@ pub(crate) type MouseExitListener =
pub(crate) type FileDropExitListener =
Box<dyn Fn(&FileDropEvent, DispatchPhase, &Hitbox, &mut Window, &mut App) + 'static>;
-pub(crate) type ScrollWheelListener =
- Box<dyn Fn(&ScrollWheelEvent, DispatchPhase, &Hitbox, &mut Window, &mut App) + 'static>;
+pub(crate) type ScrollListener =
+ Box<dyn Fn(&ScrollEvent, DispatchPhase, &Hitbox, &mut Window, &mut App) + 'static>;
pub(crate) type PinchListener =
Box<dyn Fn(&PinchEvent, DispatchPhase, &Hitbox, &mut Window, &mut App) + 'static>;
@@ -2169,7 +2184,7 @@ pub struct Interactivity {
pub(crate) mouse_move_listeners: Vec<MouseMoveListener>,
pub(crate) mouse_exit_listeners: Vec<MouseExitListener>,
pub(crate) file_drop_exit_listeners: Vec<FileDropExitListener>,
- pub(crate) scroll_wheel_listeners: Vec<ScrollWheelListener>,
+ pub(crate) scroll_listeners: Vec<ScrollListener>,
pub(crate) pinch_listeners: Vec<PinchListener>,
pub(crate) key_down_listeners: Vec<KeyDownListener>,
pub(crate) key_up_listeners: Vec<KeyUpListener>,
@@ -2422,7 +2437,7 @@ impl Interactivity {
|| !self.file_drop_exit_listeners.is_empty()
|| !self.click_listeners.is_empty()
|| !self.aux_click_listeners.is_empty()
- || !self.scroll_wheel_listeners.is_empty()
+ || !self.scroll_listeners.is_empty()
|| self.has_pinch_listeners()
|| self.drag_listener.is_some()
|| !self.drop_listeners.is_empty()
@@ -2828,9 +2843,9 @@ impl Interactivity {
})
}
- for listener in self.scroll_wheel_listeners.drain(..) {
+ for listener in self.scroll_listeners.drain(..) {
let hitbox = hitbox.clone();
- window.on_mouse_event(move |event: &ScrollWheelEvent, phase, window, cx| {
+ window.on_mouse_event(move |event: &ScrollEvent, phase, window, cx| {
listener(event, phase, &hitbox, window, cx);
})
}
@@ -3336,7 +3351,7 @@ impl Interactivity {
let line_height = window.line_height();
let hitbox = hitbox.clone();
let current_view = window.current_view();
- window.on_mouse_event(move |event: &ScrollWheelEvent, phase, window, cx| {
+ window.on_mouse_event(move |event: &ScrollEvent, phase, window, cx| {
if phase == DispatchPhase::Bubble && hitbox.should_handle_scroll(window) {
let mut scroll_offset = scroll_offset.borrow_mut();
let old_scroll_offset = *scroll_offset;
@@ -3792,7 +3807,7 @@ pub(crate) fn register_tooltip_mouse_handlers(
window.on_mouse_event({
let active_tooltip = active_tooltip.clone();
- move |_: &ScrollWheelEvent, _phase, window: &mut Window, _cx| {
+ move |_: &ScrollEvent, _phase, window: &mut Window, _cx| {
if !tooltip_id.is_some_and(|tooltip_id| tooltip_id.is_hovered(window)) {
clear_active_tooltip_if_not_hoverable(&active_tooltip, window);
}
diff --git a/crates/gpui/src/elements/list.rs b/crates/gpui/src/elements/list.rs
index fa21d107062..6d67e4072f1 100644
--- a/crates/gpui/src/elements/list.rs
+++ b/crates/gpui/src/elements/list.rs
@@ -10,7 +10,7 @@
use crate::{
AnyElement, App, AvailableSpace, Bounds, ContentMask, DispatchPhase, Edges, Element, EntityId,
FocusHandle, GlobalElementId, Hitbox, HitboxBehavior, InspectorElementId, IntoElement,
- Overflow, Pixels, Point, ScrollDelta, ScrollWheelEvent, Size, Style, StyleRefinement, Styled,
+ Overflow, Pixels, Point, ScrollDelta, ScrollEvent, Size, Style, StyleRefinement, Styled,
Window, point, px, size,
};
use collections::VecDeque;
@@ -1598,7 +1598,7 @@ impl Element for List {
let scroll_top = prepaint.layout.scroll_top;
let hitbox_id = prepaint.hitbox.id;
let mut accumulated_scroll_delta = ScrollDelta::default();
- window.on_mouse_event(move |event: &ScrollWheelEvent, phase, window, cx| {
+ window.on_mouse_event(move |event: &ScrollEvent, phase, window, cx| {
if phase == DispatchPhase::Bubble && hitbox_id.should_handle_scroll(window) {
accumulated_scroll_delta = accumulated_scroll_delta.coalesce(event.delta);
let pixel_delta = accumulated_scroll_delta.pixel_delta(px(20.));
@@ -1719,7 +1719,7 @@ impl sum_tree::SeekTarget<'_, ListItemSummary, ListItemSummary> for Height {
#[cfg(test)]
mod test {
- use gpui::{ScrollDelta, ScrollWheelEvent};
+ use gpui::{ScrollDelta, ScrollEvent};
use std::cell::Cell;
use std::rc::Rc;
@@ -1814,7 +1814,7 @@ mod test {
state.reset(5);
// And then receive a scroll event _before_ the next paint
- cx.simulate_event(ScrollWheelEvent {
+ cx.simulate_event(ScrollEvent {
position: point(px(1.), px(1.)),
delta: ScrollDelta::Pixels(point(px(0.), px(-500.))),
..Default::default()
@@ -1889,7 +1889,7 @@ mod test {
div()
.h(px(20.))
.w_full()
- .on_scroll_wheel(move |_, _, cx| {
+ .on_scroll(move |_, _, cx| {
child_saw_event.set(true);
cx.stop_propagation();
})
@@ -1908,7 +1908,7 @@ mod test {
.into_any_element()
});
- cx.simulate_event(ScrollWheelEvent {
+ cx.simulate_event(ScrollEvent {
position: point(px(50.), px(10.)),
delta: ScrollDelta::Pixels(point(px(0.), px(-30.))),
..Default::default()
@@ -2251,7 +2251,7 @@ mod test {
state.remeasure_items(5..6);
- cx.simulate_event(ScrollWheelEvent {
+ cx.simulate_event(ScrollEvent {
position: point(px(50.), px(100.)),
delta: ScrollDelta::Pixels(point(px(0.), px(-30.))),
..Default::default()
@@ -2319,7 +2319,7 @@ mod test {
// ...and then the user scrolls down by 30px before the next frame,
// landing at offset 70.
- cx.simulate_event(ScrollWheelEvent {
+ cx.simulate_event(ScrollEvent {
position: point(px(50.), px(100.)),
delta: ScrollDelta::Pixels(point(px(0.), px(-30.))),
..Default::default()
@@ -2543,7 +2543,7 @@ mod test {
// Simulate the user scrolling up.
// This should disengage follow-tail.
- cx.simulate_event(ScrollWheelEvent {
+ cx.simulate_event(ScrollEvent {
position: point(px(50.), px(100.)),
delta: ScrollDelta::Pixels(point(px(0.), px(100.))),
..Default::default()
@@ -2794,7 +2794,7 @@ mod test {
assert!(state.is_following_tail());
// Scroll up — follow_tail should suspend (not fully disengage).
- cx.simulate_event(ScrollWheelEvent {
+ cx.simulate_event(ScrollEvent {
position: point(px(50.), px(100.)),
delta: ScrollDelta::Pixels(point(px(0.), px(50.))),
..Default::default()
@@ -2802,7 +2802,7 @@ mod test {
assert!(!state.is_following_tail());
// Scroll back down to the bottom.
- cx.simulate_event(ScrollWheelEvent {
+ cx.simulate_event(ScrollEvent {
position: point(px(50.), px(100.)),
delta: ScrollDelta::Pixels(point(px(0.), px(-10000.))),
..Default::default()
@@ -2853,7 +2853,7 @@ mod test {
// Scroll up a meaningful amount — suspends follow_tail.
// 20 items × 50px = 1000px. viewport 200px. scroll_max = 800px.
// Scrolling up 200px puts us at 600px, clearly not at bottom.
- cx.simulate_event(ScrollWheelEvent {
+ cx.simulate_event(ScrollEvent {
position: point(px(50.), px(100.)),
delta: ScrollDelta::Pixels(point(px(0.), px(200.))),
..Default::default()
diff --git a/crates/gpui/src/gestures.rs b/crates/gpui/src/gestures.rs
index 3fe5b12c581..0191db5406d 100644
--- a/crates/gpui/src/gestures.rs
+++ b/crates/gpui/src/gestures.rs
@@ -3,7 +3,7 @@
//! GPUI recognizes gestures from raw [`TouchEvent`](crate::TouchEvent)s using
//! a portable recognizer. Taps synthesize mouse presses and releases so
//! existing click listeners and text selection work on mobile. Pans produce
-//! [`ScrollWheelEvent`](crate::ScrollWheelEvent)s, including post-release
+//! [`ScrollEvent`](crate::ScrollEvent)s, including post-release
//! momentum. Long presses and touch drags can be claimed by element listeners.
use std::collections::VecDeque;
@@ -15,8 +15,8 @@ use smallvec::SmallVec;
use crate::{
Axis, GestureEvent, InputEvent, IsZero, Modifiers, MouseButton, MouseDownEvent, MouseEvent,
- MouseUpEvent, Pixels, PlatformInput, Point, ScrollDelta, ScrollWheelEvent, TouchEvent, TouchId,
- TouchPhase, point, px, seal::Sealed,
+ MouseUpEvent, Pixels, PlatformInput, Point, ScrollDelta, ScrollEvent, ScrollSource, TouchEvent,
+ TouchId, TouchPhase, point, px, seal::Sealed,
};
const SCROLL_EVENT_SEPARATION: Duration = Duration::from_millis(28);
@@ -352,7 +352,7 @@ pub struct GestureKinds {
/// Long press, surfaced as [`LongPressEvent`].
pub long_press: bool,
/// Pan/scroll (including fling momentum), surfaced as
- /// [`ScrollWheelEvent`](crate::ScrollWheelEvent)s.
+ /// [`ScrollEvent`](crate::ScrollEvent)s.
pub pan: bool,
/// Pinch to zoom, surfaced as [`PinchEvent`](crate::PinchEvent)s.
pub pinch: bool,
@@ -496,7 +496,7 @@ pub(crate) struct TouchGestureRecognizer {
pub(crate) enum RecognizedTouchGesture {
/// One step of a pan (or of its post-release momentum), delivered to
/// scroll listeners at the pan's starting position.
- Scroll(ScrollWheelEvent),
+ Scroll(ScrollEvent),
/// A recognized tap, delivered as a synthesized mouse press and release.
Tap {
down: MouseDownEvent,
@@ -1028,12 +1028,13 @@ fn scroll_event(
position: Point<Pixels>,
delta: Point<Pixels>,
touch_phase: TouchPhase,
-) -> ScrollWheelEvent {
- ScrollWheelEvent {
+) -> ScrollEvent {
+ ScrollEvent {
position,
delta: ScrollDelta::Pixels(delta),
modifiers: Modifiers::default(),
touch_phase,
+ source: ScrollSource::Touch,
}
}
@@ -2111,7 +2112,7 @@ mod tests {
);
assert!(matches!(
moved.as_slice(),
- [RecognizedTouchGesture::Scroll(ScrollWheelEvent {
+ [RecognizedTouchGesture::Scroll(ScrollEvent {
touch_phase: TouchPhase::Started,
..
})]
@@ -2185,7 +2186,7 @@ mod tests {
);
assert!(matches!(
moved.as_slice(),
- [RecognizedTouchGesture::Scroll(ScrollWheelEvent {
+ [RecognizedTouchGesture::Scroll(ScrollEvent {
touch_phase: TouchPhase::Started,
..
})]
diff --git a/crates/gpui/src/interactive.rs b/crates/gpui/src/interactive.rs
index 913cf1ba790..fb6691b3f34 100644
--- a/crates/gpui/src/interactive.rs
+++ b/crates/gpui/src/interactive.rs
@@ -517,31 +517,52 @@ impl MouseMoveEvent {
}
}
-/// A mouse wheel event from the platform.
+/// One step of scrolling from a mouse wheel, trackpad, or touch pan.
#[derive(Clone, Debug, Default)]
-pub struct ScrollWheelEvent {
- /// The position of the mouse on the window.
+pub struct ScrollEvent {
+ /// The position the scroll targets. For touch pans this is where the pan
+ /// started, so the whole gesture stays with the container it began on.
pub position: Point<Pixels>,
- /// The change in scroll wheel position for this event.
+ /// The change in scroll position for this event.
pub delta: ScrollDelta,
- /// The modifiers that were held down when the mouse was moved.
+ /// The modifiers that were held down when the scroll happened.
pub modifiers: Modifiers,
- /// The phase of the touch event.
+ /// The phase of the scroll gesture.
pub touch_phase: TouchPhase,
+
+ /// The kind of input that produced this scroll.
+ pub source: ScrollSource,
+}
+
+/// The former name of [`ScrollEvent`].
+#[deprecated(note = "renamed to `ScrollEvent`")]
+pub type ScrollWheelEvent = ScrollEvent;
+
+/// The kind of input that produced a [`ScrollEvent`].
+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
+pub enum ScrollSource {
+ /// A scroll the platform reported from a pointing device, such as a mouse
+ /// wheel or a trackpad. [`ScrollDelta::precise`] tells continuous devices
+ /// apart from wheel notches.
+ #[default]
+ Pointer,
+ /// A pan of a finger on a touchscreen, recognized by GPUI, including the
+ /// momentum GPUI synthesizes after the finger lifts.
+ Touch,
}
-impl Sealed for ScrollWheelEvent {}
-impl InputEvent for ScrollWheelEvent {
+impl Sealed for ScrollEvent {}
+impl InputEvent for ScrollEvent {
fn to_platform_input(self) -> PlatformInput {
- PlatformInput::ScrollWheel(self)
+ PlatformInput::Scroll(self)
}
}
-impl MouseEvent for ScrollWheelEvent {}
+impl MouseEvent for ScrollEvent {}
-impl Deref for ScrollWheelEvent {
+impl Deref for ScrollEvent {
type Target = Modifiers;
fn deref(&self) -> &Self::Target {
@@ -549,7 +570,7 @@ impl Deref for ScrollWheelEvent {
}
}
-/// The scroll delta for a scroll wheel event.
+/// The scroll delta for a [`ScrollEvent`].
#[derive(Clone, Copy, Debug)]
pub enum ScrollDelta {
/// An exact scroll delta in pixels.
@@ -785,8 +806,9 @@ pub enum PlatformInput {
MouseMove(MouseMoveEvent),
/// The mouse exited the window.
MouseExited(MouseExitEvent),
- /// The scroll wheel was used.
- ScrollWheel(ScrollWheelEvent),
+ /// A mouse wheel or trackpad scrolled. Touch pans reach the window as
+ /// [`PlatformInput::Touch`] and are recognized into scrolls by GPUI.
+ Scroll(ScrollEvent),
/// A pinch gesture was performed.
Pinch(PinchEvent),
/// A long-press gesture recognized from touch input.
@@ -810,7 +832,7 @@ impl PlatformInput {
PlatformInput::MouseMove(event) => Some(event),
PlatformInput::MousePressure(event) => Some(event),
PlatformInput::MouseExited(event) => Some(event),
- PlatformInput::ScrollWheel(event) => Some(event),
+ PlatformInput::Scroll(event) => Some(event),
PlatformInput::Pinch(event) => Some(event),
PlatformInput::LongPress(event) => Some(event),
PlatformInput::TouchDrag(event) => Some(event),
@@ -829,7 +851,7 @@ impl PlatformInput {
PlatformInput::MouseMove(_) => None,
PlatformInput::MousePressure(_) => None,
PlatformInput::MouseExited(_) => None,
- PlatformInput::ScrollWheel(_) => None,
+ PlatformInput::Scroll(_) => None,
PlatformInput::Pinch(_) => None,
PlatformInput::LongPress(_) => None,
PlatformInput::TouchDrag(_) => None,
@@ -850,7 +872,7 @@ impl PlatformInput {
PlatformInput::MousePressure(_) => "mouse_pressure",
PlatformInput::MouseMove(_) => "mouse_move",
PlatformInput::MouseExited(_) => "mouse_exited",
- PlatformInput::ScrollWheel(_) => "scroll_wheel",
+ PlatformInput::Scroll(_) => "scroll",
PlatformInput::Pinch(_) => "pinch",
PlatformInput::LongPress(_) => "long_press",
PlatformInput::TouchDrag(_) => "touch_drag",
diff --git a/crates/gpui/src/window.rs b/crates/gpui/src/window.rs
index 9d861155bcd..b5fdcd31eb3 100644
--- a/crates/gpui/src/window.rs
+++ b/crates/gpui/src/window.rs
@@ -785,7 +785,7 @@ impl HitboxId {
impl HitboxId {
/// Checks if the hitbox with this ID is currently hovered. Returns `false` during keyboard
/// input modality so that keyboard navigation suppresses hover highlights. Except when handling
- /// `ScrollWheelEvent`, this is typically what you want when determining whether to handle mouse
+ /// `ScrollEvent`, this is typically what you want when determining whether to handle mouse
/// events or paint hover styles.
///
/// See [`Hitbox::is_hovered`] for details.
@@ -823,7 +823,7 @@ impl HitboxId {
}
/// Checks if the hitbox with this ID contains the mouse and should handle scroll events.
- /// Typically this should only be used when handling `ScrollWheelEvent`, and otherwise
+ /// Typically this should only be used when handling `ScrollEvent`, and otherwise
/// `is_hovered` should be used. See the documentation of `Hitbox::is_hovered` for details about
/// this distinction.
pub fn should_handle_scroll(self, window: &Window) -> bool {
@@ -853,7 +853,7 @@ pub struct Hitbox {
impl Hitbox {
/// Checks if the hitbox is currently hovered. Returns `false` during keyboard input modality
/// so that keyboard navigation suppresses hover highlights. Except when handling
- /// `ScrollWheelEvent`, this is typically what you want when determining whether to handle mouse
+ /// `ScrollEvent`, this is typically what you want when determining whether to handle mouse
/// events or paint hover styles.
///
/// This can return `false` even when the hitbox contains the mouse, if a hitbox in front of
@@ -861,7 +861,7 @@ impl Hitbox {
/// `HitboxBehavior::BlockMouseExceptScroll` (`InteractiveElement::block_mouse_except_scroll`),
/// or if the current input modality is keyboard (see [`Window::last_input_was_keyboard`]).
///
- /// Handling of `ScrollWheelEvent` should typically use `should_handle_scroll` instead.
+ /// Handling of `ScrollEvent` should typically use `should_handle_scroll` instead.
/// Concretely, this is due to use-cases like overlays that cause the elements under to be
/// non-interactive while still allowing scrolling. More abstractly, this is because
/// `is_hovered` is about element interactions directly under the mouse - mouse moves, clicks,
@@ -883,7 +883,7 @@ impl Hitbox {
}
/// Checks if the hitbox contains the mouse and should handle scroll events. Typically this
- /// should only be used when handling `ScrollWheelEvent`, and otherwise `is_hovered` should be
+ /// should only be used when handling `ScrollEvent`, and otherwise `is_hovered` should be
/// used. See the documentation of `Hitbox::is_hovered` for details about this distinction.
///
/// This can return `false` even when the hitbox contains the mouse, if a hitbox in front of
@@ -930,7 +930,7 @@ pub enum HitboxBehavior {
/// [`InteractiveElement::block_mouse_except_scroll`].
///
/// For mouse handlers that check those hitboxes, this behaves the same as registering a
- /// bubble-phase handler for every mouse event type **except** `ScrollWheelEvent`:
+ /// bubble-phase handler for every mouse event type **except** `ScrollEvent`:
///
/// ```ignore
/// window.on_mouse_event(move |_: &EveryMouseEventTypeExceptScroll, phase, window, cx| {
@@ -940,7 +940,7 @@ pub enum HitboxBehavior {
/// })
/// ```
///
- /// See the documentation of [`Hitbox::is_hovered`] for details of why `ScrollWheelEvent` is
+ /// See the documentation of [`Hitbox::is_hovered`] for details of why `ScrollEvent` is
/// handled differently than other mouse events. If also blocking these scroll events is
/// desired, then a `cx.stop_propagation()` handler like the one above can be used.
///
@@ -5683,10 +5683,10 @@ impl Window {
self.capslock = modifiers_changed.capslock;
PlatformInput::ModifiersChanged(modifiers_changed)
}
- PlatformInput::ScrollWheel(scroll_wheel) => {
+ PlatformInput::Scroll(scroll_wheel) => {
self.mouse_position = scroll_wheel.position;
self.modifiers = scroll_wheel.modifiers;
- PlatformInput::ScrollWheel(scroll_wheel)
+ PlatformInput::Scroll(scroll_wheel)
}
PlatformInput::Pinch(pinch) => {
self.mouse_position = pinch.position;
@@ -7282,7 +7282,7 @@ impl Window {
inspector.select(inspector_id, self);
}
});
- } else if let Some(event) = event.downcast_ref::<crate::ScrollWheelEvent>() {
+ } else if let Some(event) = event.downcast_ref::<crate::ScrollEvent>() {
// This should be kept in sync with SCROLL_LINES in x11 platform.
const SCROLL_LINES: f32 = 3.0;
const SCROLL_PIXELS_PER_LAYER: f32 = 36.0;
diff --git a/crates/gpui_ios/src/ios/events.rs b/crates/gpui_ios/src/ios/events.rs
index 0cb93587dbd..a730070f09f 100644
--- a/crates/gpui_ios/src/ios/events.rs
+++ b/crates/gpui_ios/src/ios/events.rs
@@ -1,7 +1,13 @@
//! Conversion from UIKit events to GPUI input events.
-use gpui::{Pixels, Point, TouchId, TouchPhase, px};
-use objc2_ui_kit::{UITouch, UITouchPhase, UIView};
+use gpui::{
+ Modifiers, Pixels, Point, ScrollDelta, ScrollEvent, ScrollSource, TouchId, TouchPhase, px,
+};
+use objc2_core_foundation::CGPoint;
+use objc2_ui_kit::{
+ UIGestureRecognizerState, UIKeyModifierFlags, UIPanGestureRecognizer, UITouch, UITouchPhase,
+ UIView,
+};
pub fn touch_location_in_view(touch: &UITouch, view: &UIView) -> Point<Pixels> {
let location = touch.locationInView(Some(view));
@@ -21,6 +27,47 @@ pub fn touch_id(touch: &UITouch) -> TouchId {
TouchId(touch as *const UITouch as usize as u64)
}
+/// Converts one step of a trackpad or mouse-wheel scroll gesture.
+///
+/// The recognizer's translation is reset after each step, so every event carries
+/// only the movement since the previous one. UIKit reports the translation in
+/// the direction the content should move, which matches GPUI's pixel deltas.
+/// Returns `None` for states that carry no scroll.
+pub fn scroll_event(recognizer: &UIPanGestureRecognizer, view: &UIView) -> Option<ScrollEvent> {
+ let touch_phase = match recognizer.state() {
+ UIGestureRecognizerState::Began => TouchPhase::Started,
+ UIGestureRecognizerState::Changed => TouchPhase::Moved,
+ UIGestureRecognizerState::Ended => TouchPhase::Ended,
+ UIGestureRecognizerState::Cancelled | UIGestureRecognizerState::Failed => {
+ TouchPhase::Cancelled
+ }
+ _ => return None,
+ };
+ let translation = recognizer.translationInView(Some(view));
+ recognizer.setTranslation_inView(CGPoint::ZERO, Some(view));
+ let location = recognizer.locationInView(Some(view));
+ Some(ScrollEvent {
+ position: Point::new(px(location.x as f32), px(location.y as f32)),
+ delta: ScrollDelta::Pixels(Point::new(
+ px(translation.x as f32),
+ px(translation.y as f32),
+ )),
+ modifiers: modifiers(recognizer.modifierFlags()),
+ touch_phase,
+ source: ScrollSource::Pointer,
+ })
+}
+
+fn modifiers(flags: UIKeyModifierFlags) -> Modifiers {
+ Modifiers {
+ control: flags.contains(UIKeyModifierFlags::Control),
+ alt: flags.contains(UIKeyModifierFlags::Alternate),
+ shift: flags.contains(UIKeyModifierFlags::Shift),
+ platform: flags.contains(UIKeyModifierFlags::Command),
+ function: false,
+ }
+}
+
pub fn touch_force(touch: &UITouch) -> Option<f32> {
let maximum_force = touch.maximumPossibleForce();
if maximum_force <= 0.0 {
diff --git a/crates/gpui_ios/src/ios/window.rs b/crates/gpui_ios/src/ios/window.rs
index 2c574dc3f96..be68f04ac53 100644
--- a/crates/gpui_ios/src/ios/window.rs
+++ b/crates/gpui_ios/src/ios/window.rs
@@ -22,18 +22,23 @@ use gpui::{
};
use gpui_apple::metal_renderer::{Context as MetalContext, MetalRenderer};
use objc2::rc::Retained;
-use objc2::runtime::AnyClass;
-use objc2::{ClassType, DefinedClass, MainThreadMarker, MainThreadOnly, define_class, msg_send};
+use objc2::runtime::{AnyClass, AnyObject};
+use objc2::{
+ ClassType, DefinedClass, MainThreadMarker, MainThreadOnly, define_class, msg_send, sel,
+};
use objc2_core_foundation::{CGPoint, CGRect, CGSize};
-use objc2_foundation::{NSNotification, NSNotificationCenter, NSObjectProtocol, NSSet, NSValue};
+use objc2_foundation::{
+ NSArray, NSNotification, NSNotificationCenter, NSObjectProtocol, NSSet, NSValue,
+};
use objc2_quartz_core::CAMetalLayer;
use objc2_ui_kit::{
NSValueUIGeometryExtensions, UIKeyboardFrameEndUserInfoKey,
UIKeyboardWillChangeFrameNotification, UIKeyboardWillHideNotification, UIStatusBarStyle,
};
use objc2_ui_kit::{
- UIEvent, UIScreen, UITouch, UITraitCollection, UITraitEnvironment, UIUserInterfaceStyle,
- UIView, UIViewAutoresizing, UIViewController, UIWindow, UIWindowScene,
+ UIEvent, UIPanGestureRecognizer, UIScreen, UIScrollTypeMask, UITouch, UITraitCollection,
+ UITraitEnvironment, UIUserInterfaceStyle, UIView, UIViewAutoresizing, UIViewController,
+ UIWindow, UIWindowScene,
};
use parking_lot::Mutex;
use raw_window_handle::{HasDisplayHandle, HasWindowHandle, UiKitDisplayHandle, UiKitWindowHandle};
@@ -177,6 +182,12 @@ define_class!(
self.handle_touches(touches, event);
}
+ #[unsafe(method(handleScroll:))]
+ fn handle_scroll(&self, recognizer: &UIPanGestureRecognizer) {
+ self.ivars()
+ .with_window(|window| window.handle_scroll(recognizer));
+ }
+
}
);
@@ -304,6 +315,24 @@ impl IosWindow {
view.setUserInteractionEnabled(true);
view.setMultipleTouchEnabled(true);
+ // Trackpad and mouse-wheel scrolling reaches UIKit apps only through a
+ // pan recognizer that accepts scroll types. With no allowed touch types
+ // it never claims finger touches, so those keep reaching `touchesBegan`
+ // and GPUI's own recognizer.
+ let scroll_target: &AnyObject = &view;
+ // SAFETY: `MetalView` implements `handleScroll:` and owns the recognizer.
+ let scroll_recognizer = unsafe {
+ UIPanGestureRecognizer::initWithTarget_action(
+ UIPanGestureRecognizer::alloc(main_thread),
+ Some(scroll_target),
+ Some(sel!(handleScroll:)),
+ )
+ };
+ scroll_recognizer.setAllowedScrollTypesMask(UIScrollTypeMask::All);
+ scroll_recognizer.setAllowedTouchTypes(&NSArray::new());
+ scroll_recognizer.setCancelsTouchesInView(false);
+ view.addGestureRecognizer(&scroll_recognizer);
+
let view_controller = ViewController::new(main_thread);
view_controller.setView(Some(&view));
window.setRootViewController(Some(&view_controller));
@@ -462,6 +491,17 @@ impl IosWindowState {
.with(|callback| callback(PlatformInput::Touch(event)));
}
+ /// Delivers one step of a trackpad or mouse-wheel scroll gesture.
+ fn handle_scroll(&self, recognizer: &UIPanGestureRecognizer) {
+ let Some(event) = scroll_event(recognizer, &self.view) else {
+ return;
+ };
+ self.mouse_position.set(event.position);
+ self.modifiers.set(event.modifiers);
+ self.input_callback
+ .with(|callback| callback(PlatformInput::Scroll(event)));
+ }
+
fn handle_keyboard_dismiss_touch(&self, event: &TouchEvent) {
if self.keyboard_height.get() <= 0. {
self.keyboard_dismiss_touch.set(None);
diff --git a/crates/gpui_linux/src/linux/wayland/client.rs b/crates/gpui_linux/src/linux/wayland/client.rs
index 84f4d0f18fd..2d40cf7fa94 100644
--- a/crates/gpui_linux/src/linux/wayland/client.rs
+++ b/crates/gpui_linux/src/linux/wayland/client.rs
@@ -104,8 +104,8 @@ use gpui::{
KeyUpEvent, Keystroke, Modifiers, ModifiersChangedEvent, MouseButton, MouseDownEvent,
MouseExitEvent, MouseMoveEvent, MouseUpEvent, NavigationDirection, Pixels, PlatformDisplay,
PlatformFrameSignal, PlatformInput, PlatformKeyboardLayout, PlatformWindow, Point, ScrollDelta,
- ScrollWheelEvent, SharedString, Size, TouchPhase, WindowButtonLayout, WindowKind, WindowParams,
- point, px, size,
+ ScrollEvent, ScrollSource, SharedString, Size, TouchPhase, WindowButtonLayout, WindowKind,
+ WindowParams, point, px, size,
};
use gpui_wgpu::{CompositorGpuHint, GpuContext};
use wayland_protocols::wp::linux_dmabuf::zv1::client::{
@@ -2690,11 +2690,12 @@ impl Dispatch<wl_pointer::WlPointer, ()> for WaylandClientStatePtr {
let discrete = state.discrete_scroll_delta.take();
if let Some(continuous) = continuous {
if let Some(window) = state.mouse_focused_window.clone() {
- let input = PlatformInput::ScrollWheel(ScrollWheelEvent {
+ let input = PlatformInput::Scroll(ScrollEvent {
position: state.mouse_location.unwrap(),
delta: ScrollDelta::Pixels(continuous),
modifiers: state.modifiers,
touch_phase: TouchPhase::Moved,
+ source: ScrollSource::Pointer,
});
drop(state);
window.handle_input(input);
@@ -2702,11 +2703,12 @@ impl Dispatch<wl_pointer::WlPointer, ()> for WaylandClientStatePtr {
} else if let Some(discrete) = discrete
&& let Some(window) = state.mouse_focused_window.clone()
{
- let input = PlatformInput::ScrollWheel(ScrollWheelEvent {
+ let input = PlatformInput::Scroll(ScrollEvent {
position: state.mouse_location.unwrap(),
delta: ScrollDelta::Lines(discrete),
modifiers: state.modifiers,
touch_phase: TouchPhase::Moved,
+ source: ScrollSource::Pointer,
});
drop(state);
window.handle_input(input);
diff --git a/crates/gpui_linux/src/linux/x11/client.rs b/crates/gpui_linux/src/linux/x11/client.rs
index 601eb938df4..e21f019c649 100644
--- a/crates/gpui_linux/src/linux/x11/client.rs
+++ b/crates/gpui_linux/src/linux/x11/client.rs
@@ -1295,9 +1295,11 @@ impl X11Client {
ScrollDirection::Left => Point::new(SCROLL_LINES, 0.0),
ScrollDirection::Right => Point::new(-SCROLL_LINES, 0.0),
};
- window.handle_input(PlatformInput::ScrollWheel(
- make_scroll_wheel_event(position, scroll_delta, modifiers),
- ));
+ window.handle_input(PlatformInput::Scroll(make_scroll_wheel_event(
+ position,
+ scroll_delta,
+ modifiers,
+ )));
}
}
None => {
@@ -1383,7 +1385,7 @@ impl X11Client {
let scroll_delta = get_scroll_delta_and_update_state(pointer, &event);
drop(state);
if let Some(scroll_delta) = scroll_delta {
- window.handle_input(PlatformInput::ScrollWheel(make_scroll_wheel_event(
+ window.handle_input(PlatformInput::Scroll(make_scroll_wheel_event(
position,
scroll_delta,
modifiers,
@@ -2572,7 +2574,7 @@ fn make_scroll_wheel_event(
position: Point<Pixels>,
scroll_delta: Point<f32>,
modifiers: Modifiers,
-) -> gpui::ScrollWheelEvent {
+) -> gpui::ScrollEvent {
// When shift is held down, vertical scrolling turns into horizontal scrolling.
let delta = if modifiers.shift {
Point {
@@ -2582,11 +2584,12 @@ fn make_scroll_wheel_event(
} else {
scroll_delta
};
- gpui::ScrollWheelEvent {
+ gpui::ScrollEvent {
position,
delta: ScrollDelta::Lines(delta),
modifiers,
touch_phase: TouchPhase::default(),
+ source: gpui::ScrollSource::Pointer,
}
}
diff --git a/crates/gpui_macos/src/events.rs b/crates/gpui_macos/src/events.rs
index 71bcb105e8a..c15f7e4bb88 100644
--- a/crates/gpui_macos/src/events.rs
+++ b/crates/gpui_macos/src/events.rs
@@ -2,7 +2,7 @@ use gpui::{
Capslock, KeyDownEvent, KeyUpEvent, Keystroke, Modifiers, ModifiersChangedEvent, MouseButton,
MouseDownEvent, MouseExitEvent, MouseMoveEvent, MousePressureEvent, MouseUpEvent,
NavigationDirection, PinchEvent, Pixels, PlatformInput, PressureStage, ScrollDelta,
- ScrollWheelEvent, TouchPhase, point, px,
+ ScrollEvent, ScrollSource, TouchPhase, point, px,
};
use crate::{
@@ -275,7 +275,7 @@ pub(crate) unsafe fn platform_input_from_native(
ScrollDelta::Lines(raw_data)
};
- PlatformInput::ScrollWheel(ScrollWheelEvent {
+ PlatformInput::Scroll(ScrollEvent {
position: point(
px(native_event.locationInWindow().x as f32),
window_height - px(native_event.locationInWindow().y as f32),
@@ -283,6 +283,7 @@ pub(crate) unsafe fn platform_input_from_native(
delta,
touch_phase: phase,
modifiers: read_modifiers(native_event),
+ source: ScrollSource::Pointer,
})
}),
NSEventType::NSLeftMouseDragged
diff --git a/crates/gpui_macos/src/window.rs b/crates/gpui_macos/src/window.rs
index dbbf295b693..2ca0e202ffb 100644
--- a/crates/gpui_macos/src/window.rs
+++ b/crates/gpui_macos/src/window.rs
@@ -2817,7 +2817,7 @@ extern "C" fn handle_view_event(this: &Object, _: Sel, native_event: id) {
| PlatformInput::MouseUp(_)
| PlatformInput::MousePressure(_)
| PlatformInput::MouseExited(_)
- | PlatformInput::ScrollWheel(_)
+ | PlatformInput::Scroll(_)
| PlatformInput::Pinch(_)
) {
lock.cursor_visible.store(true, Ordering::Relaxed);
diff --git a/crates/gpui_web/src/events.rs b/crates/gpui_web/src/events.rs
index 9908b423470..4ef22cf3434 100644
--- a/crates/gpui_web/src/events.rs
+++ b/crates/gpui_web/src/events.rs
@@ -4,8 +4,8 @@ use gpui::{
Capslock, ClipboardEntry, ClipboardItem, ClipboardString, DispatchEventResult, GestureTuning,
Image, ImageFormat, KeyDownEvent, KeyUpEvent, Keystroke, Modifiers, ModifiersChangedEvent,
MouseButton, MouseDownEvent, MouseExitEvent, MouseMoveEvent, MouseUpEvent, NavigationDirection,
- Pixels, PlatformInput, Point, ScrollDelta, ScrollWheelEvent, TouchEvent, TouchId, TouchPhase,
- point, px,
+ Pixels, PlatformInput, Point, ScrollDelta, ScrollEvent, ScrollSource, TouchEvent, TouchId,
+ TouchPhase, point, px,
};
use wasm_bindgen::prelude::*;
@@ -663,11 +663,12 @@ impl WebWindowInner {
current_state.modifiers = modifiers;
}
- this.dispatch_input(PlatformInput::ScrollWheel(ScrollWheelEvent {
+ this.dispatch_input(PlatformInput::Scroll(ScrollEvent {
position,
delta,
modifiers,
touch_phase: TouchPhase::Moved,
+ source: ScrollSource::Pointer,
}));
})
}
diff --git a/crates/gpui_windows/src/direct_manipulation.rs b/crates/gpui_windows/src/direct_manipulation.rs
index 9adcbed343b..4ad4cc77b3b 100644
--- a/crates/gpui_windows/src/direct_manipulation.rs
+++ b/crates/gpui_windows/src/direct_manipulation.rs
@@ -170,11 +170,12 @@ impl DirectManipulationEventHandler {
GestureKind::Scroll => {
self.pending_events
.borrow_mut()
- .push(PlatformInput::ScrollWheel(ScrollWheelEvent {
+ .push(PlatformInput::Scroll(ScrollEvent {
position,
delta: ScrollDelta::Pixels(point(px(0.0), px(0.0))),
modifiers,
touch_phase: TouchPhase::Ended,
+ source: ScrollSource::Pointer,
}));
}
GestureKind::Pinch => {
@@ -324,11 +325,12 @@ impl IDirectManipulationViewportEventHandler_Impl for DirectManipulationEventHan
self.scroll_phase.set(TouchPhase::Moved);
self.pending_events
.borrow_mut()
- .push(PlatformInput::ScrollWheel(ScrollWheelEvent {
+ .push(PlatformInput::Scroll(ScrollEvent {
position,
delta: ScrollDelta::Pixels(point(px(dx), px(dy))),
modifiers,
touch_phase,
+ source: ScrollSource::Pointer,
}));
}
GestureKind::Pinch => {
diff --git a/crates/gpui_windows/src/events.rs b/crates/gpui_windows/src/events.rs
index 809d688ed9b..08f91bd626b 100644
--- a/crates/gpui_windows/src/events.rs
+++ b/crates/gpui_windows/src/events.rs
@@ -570,7 +570,7 @@ impl WindowsWindowInner {
y: lparam.signed_hiword().into(),
};
unsafe { ScreenToClient(handle, &mut cursor_point).ok().log_err() };
- let input = PlatformInput::ScrollWheel(ScrollWheelEvent {
+ let input = PlatformInput::Scroll(ScrollEvent {
position: logical_point(cursor_point.x as f32, cursor_point.y as f32, scale_factor),
delta: ScrollDelta::Lines(match modifiers.shift {
true => Point {
@@ -584,6 +584,7 @@ impl WindowsWindowInner {
}),
modifiers,
touch_phase: TouchPhase::Moved,
+ source: ScrollSource::Pointer,
});
let handled = !func(input).propagate;
self.state.callbacks.input.set(Some(func));
@@ -614,7 +615,7 @@ impl WindowsWindowInner {
y: lparam.signed_hiword().into(),
};
unsafe { ScreenToClient(handle, &mut cursor_point).ok().log_err() };
- let event = PlatformInput::ScrollWheel(ScrollWheelEvent {
+ let event = PlatformInput::Scroll(ScrollEvent {
position: logical_point(cursor_point.x as f32, cursor_point.y as f32, scale_factor),
delta: ScrollDelta::Lines(Point {
x: wheel_distance,
@@ -622,6 +623,7 @@ impl WindowsWindowInner {
}),
modifiers: current_modifiers(),
touch_phase: TouchPhase::Moved,
+ source: ScrollSource::Pointer,
});
let handled = !func(event).propagate;
self.state.callbacks.input.set(Some(func));
diff --git a/crates/image_viewer/src/image_viewer.rs b/crates/image_viewer/src/image_viewer.rs
index 426430619f8..95109499db3 100644
--- a/crates/image_viewer/src/image_viewer.rs
+++ b/crates/image_viewer/src/image_viewer.rs
@@ -13,9 +13,9 @@ use gpui::{
AnyElement, App, Bounds, Context, DispatchPhase, Element, ElementId, Entity, EventEmitter,
FocusHandle, Focusable, Font, GlobalElementId, InspectorElementId, InteractiveElement,
IntoElement, LayoutId, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent,
- ParentElement, PinchEvent, Pixels, Point, Render, RenderImage, ScrollDelta, ScrollWheelEvent,
- Style, Styled, Subscription, Task, WeakEntity, Window, actions, checkerboard, div, img, point,
- px, size,
+ ParentElement, PinchEvent, Pixels, Point, Render, RenderImage, ScrollDelta, ScrollEvent, Style,
+ Styled, Subscription, Task, WeakEntity, Window, actions, checkerboard, div, img, point, px,
+ size,
};
use language::File as _;
use persistence::ImageViewerDb;
@@ -288,7 +288,7 @@ impl ImageView {
fn handle_scroll_wheel(
&mut self,
- event: &ScrollWheelEvent,
+ event: &ScrollEvent,
_window: &mut Window,
cx: &mut Context<Self>,
) {
@@ -787,7 +787,7 @@ impl Render for ImageView {
} else {
gpui::CursorStyle::OpenHand
})
- .on_scroll_wheel(cx.listener(Self::handle_scroll_wheel))
+ .on_scroll(cx.listener(Self::handle_scroll_wheel))
.on_pinch(cx.listener(Self::handle_pinch))
.on_mouse_down(MouseButton::Left, cx.listener(Self::handle_mouse_down))
.on_mouse_down(MouseButton::Middle, cx.listener(Self::handle_mouse_down))
diff --git a/crates/keymap_editor/src/keymap_editor.rs b/crates/keymap_editor/src/keymap_editor.rs
index c081fcbd198..2fdb0822cb3 100644
--- a/crates/keymap_editor/src/keymap_editor.rs
+++ b/crates/keymap_editor/src/keymap_editor.rs
@@ -19,8 +19,8 @@ use gpui::{
Action, AppContext as _, AsyncApp, ClickEvent, Context, DismissEvent, Entity, EventEmitter,
FocusHandle, Focusable, Global, IsZero,
KeyBindingContextPredicate::{And, Descendant, Equal, Identifier, Not, NotEqual, Or},
- KeyContext, KeybindingKeystroke, MouseButton, PlatformKeyboardMapper, Point, ScrollStrategy,
- ScrollWheelEvent, Stateful, StyledText, Subscription, Task, TextStyleRefinement, WeakEntity,
+ KeyContext, KeybindingKeystroke, MouseButton, PlatformKeyboardMapper, Point, ScrollEvent,
+ ScrollStrategy, Stateful, StyledText, Subscription, Task, TextStyleRefinement, WeakEntity,
actions, anchored, deferred, div,
};
use language::{Language, LanguageConfig, ToOffset as _};
@@ -2373,7 +2373,7 @@ impl Render for KeymapEditor {
}),
),
)
- .on_scroll_wheel(cx.listener(|this, event: &ScrollWheelEvent, _, cx| {
+ .on_scroll(cx.listener(|this, event: &ScrollEvent, _, cx| {
// This ensures that the menu is not dismissed in cases where scroll events
// with a delta of zero are emitted
if !event.delta.pixel_delta(px(1.)).y.is_zero() {
diff --git a/crates/markdown/src/markdown.rs b/crates/markdown/src/markdown.rs
index 10bd60d62cf..fbd52173a93 100644
--- a/crates/markdown/src/markdown.rs
+++ b/crates/markdown/src/markdown.rs
@@ -5235,7 +5235,7 @@ mod tests {
use gpui::{
Background, DevicePixels, Font, FontId, FontMetrics, FontRun, GlyphId, LineLayout,
Modifiers, NoopTextSystem, PlatformTextSystem, RenderGlyphParams, RenderImage, ScrollDelta,
- ScrollWheelEvent, Size, TestAppContext, TestDispatcher, TextRenderingMode, TouchPhase,
+ ScrollEvent, Size, TestAppContext, TestDispatcher, TextRenderingMode, TouchPhase,
UpdateGlobal, VisualTestContext, size,
};
use language::{Language, LanguageConfig, LanguageMatcher};
@@ -5479,11 +5479,12 @@ mod tests {
Some(visible_character_index),
);
- cx.simulate_event(ScrollWheelEvent {
+ cx.simulate_event(ScrollEvent {
position: visible_position,
delta: ScrollDelta::Pixels(point(px(-400.), px(0.))),
modifiers: Modifiers::default(),
touch_phase: TouchPhase::Moved,
+ source: gpui::ScrollSource::Pointer,
});
cx.run_until_parked();
let rendered = rendered_text
@@ -7882,11 +7883,12 @@ mod tests {
(event_position, right_cell_bounds)
};
- cx.simulate_event(ScrollWheelEvent {
+ cx.simulate_event(ScrollEvent {
position: event_position,
delta: ScrollDelta::Pixels(point(px(-100.), px(0.))),
modifiers: Modifiers::default(),
touch_phase: TouchPhase::Moved,
+ source: gpui::ScrollSource::Pointer,
});
cx.run_until_parked();
@@ -7978,11 +7980,12 @@ mod tests {
assert_eq!(visible_bounds.left(), quad_bounds.left());
let event_position = visible_bounds.center();
- cx.simulate_event(ScrollWheelEvent {
+ cx.simulate_event(ScrollEvent {
position: event_position,
delta: ScrollDelta::Pixels(point(px(-100.), px(0.))),
modifiers: Modifiers::default(),
touch_phase: TouchPhase::Moved,
+ source: gpui::ScrollSource::Pointer,
});
cx.run_until_parked();
diff --git a/crates/markdown/src/mermaid.rs b/crates/markdown/src/mermaid.rs
index 63aae2aacbb..9af9e569e76 100644
--- a/crates/markdown/src/mermaid.rs
+++ b/crates/markdown/src/mermaid.rs
@@ -1,8 +1,8 @@
use collections::HashMap;
use gpui::{
Animation, AnimationExt, AnyElement, App, ClipboardItem, Context, Entity, ImageSource,
- ParsedSvg, RenderImage, SMOOTH_SVG_SCALE_FACTOR, ScrollDelta, ScrollHandle, ScrollWheelEvent,
- Size, Stateful, StyledText, Task, Window, img, pulsating_between, size,
+ ParsedSvg, RenderImage, SMOOTH_SVG_SCALE_FACTOR, ScrollDelta, ScrollEvent, ScrollHandle, Size,
+ Stateful, StyledText, Task, Window, img, pulsating_between, size,
};
use std::collections::BTreeMap;
use std::ops::Range;
@@ -544,7 +544,7 @@ fn on_mermaid_zoom_scroll(
markdown: Entity<Markdown>,
source_offset: usize,
on_zoom: Option<MermaidZoomCallback>,
-) -> impl Fn(&ScrollWheelEvent, &mut Window, &mut App) + 'static {
+) -> impl Fn(&ScrollEvent, &mut Window, &mut App) + 'static {
move |event, window, cx| {
if !(event.modifiers.control || event.modifiers.platform) {
return;
@@ -760,7 +760,7 @@ fn mermaid_scroll_container(
.w_full()
.overflow_x_scroll()
.track_scroll(scroll_handle)
- .on_scroll_wheel(on_mermaid_zoom_scroll(markdown, source_offset, on_zoom));
+ .on_scroll(on_mermaid_zoom_scroll(markdown, source_offset, on_zoom));
// Without this, gpui maps vertical wheel deltas onto the x axis for
// x-only scroll containers (see `paint_scroll_listener` in gpui's div),
// hijacking plain vertical scrolls. Restricting to the actual axis lets
diff --git a/crates/miniprofiler_ui/src/miniprofiler_ui.rs b/crates/miniprofiler_ui/src/miniprofiler_ui.rs
index a2926ef23a8..6f6ccf7156d 100644
--- a/crates/miniprofiler_ui/src/miniprofiler_ui.rs
+++ b/crates/miniprofiler_ui/src/miniprofiler_ui.rs
@@ -664,7 +664,7 @@ impl Render for ProfilerWindow {
}
})
.p_4()
- .on_scroll_wheel(cx.listener(|this, _, _, cx| {
+ .on_scroll(cx.listener(|this, _, _, cx| {
this.autoscroll = false;
cx.notify();
}))
diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs
index f7bedca9993..64854e8c70d 100644
--- a/crates/project_panel/src/project_panel.rs
+++ b/crates/project_panel/src/project_panel.rs
@@ -7923,7 +7923,7 @@ impl Render for ProjectPanel {
cx,
)
.flex_grow_1()
- .on_scroll_wheel({
+ .on_scroll({
let scroll_handle = self.scroll_handle.clone();
let entity_id = cx.entity().entity_id();
move |event, window, cx| {
diff --git a/crates/settings_ui/src/settings_ui.rs b/crates/settings_ui/src/settings_ui.rs
index 857a0ce621a..f2eef116d96 100644
--- a/crates/settings_ui/src/settings_ui.rs
+++ b/crates/settings_ui/src/settings_ui.rs
@@ -6189,10 +6189,10 @@ pub mod test {
});
draw_settings_page(&view, px(400.), px(600.) + last_height * 2., cx);
draw_settings_page(&view, px(400.), px(600.) + last_height, cx);
- cx.simulate_event(gpui::ScrollWheelEvent {
+ cx.simulate_event(gpui::ScrollEvent {
position: point(px(200.), px(100.)),
delta: gpui::ScrollDelta::Pixels(point(px(0.), -last_height)),
- ..gpui::ScrollWheelEvent::default()
+ ..gpui::ScrollEvent::default()
});
draw_settings_page(&view, px(400.), px(600.), cx);
let viewport = list_state.viewport_bounds();
@@ -6302,10 +6302,10 @@ pub mod test {
});
let expected_offset = match input {
ScrollInput::Wheel => {
- cx.simulate_event(gpui::ScrollWheelEvent {
+ cx.simulate_event(gpui::ScrollEvent {
position: point(px(200.), px(100.)),
delta: gpui::ScrollDelta::Pixels(point(px(0.), px(-32.))),
- ..gpui::ScrollWheelEvent::default()
+ ..gpui::ScrollEvent::default()
});
px(-32.)
}
diff --git a/crates/terminal/src/mappings/mouse.rs b/crates/terminal/src/mappings/mouse.rs
index fa5edaee256..fdfb3083f75 100644
--- a/crates/terminal/src/mappings/mouse.rs
+++ b/crates/terminal/src/mappings/mouse.rs
@@ -3,7 +3,7 @@ use std::iter::repeat;
/// Most of the code, and specifically the constants, in this are copied from Alacritty,
/// with modifications for our circumstances
-use gpui::{Modifiers, MouseButton, Pixels, Point as GpuiPoint, ScrollWheelEvent, px};
+use gpui::{Modifiers, MouseButton, Pixels, Point as GpuiPoint, ScrollEvent, px};
use crate::{Modes, Point, SelectionSide, TerminalBounds};
@@ -58,7 +58,7 @@ impl MouseButtonCode {
}
}
- fn from_scroll(e: &ScrollWheelEvent) -> Self {
+ fn from_scroll(e: &ScrollEvent) -> Self {
let is_positive = match e.delta {
gpui::ScrollDelta::Pixels(pixels) => pixels.y > px(0.),
gpui::ScrollDelta::Lines(lines) => lines.y > 0.,
@@ -79,7 +79,7 @@ impl MouseButtonCode {
pub(crate) fn scroll_report(
point: Point,
scroll_lines: i32,
- e: &ScrollWheelEvent,
+ e: &ScrollEvent,
mode: Modes,
) -> Option<impl Iterator<Item = Vec<u8>>> {
if mode.intersects(Modes::MOUSE_MODE) {
@@ -105,7 +105,7 @@ mod tests {
fn scroll_report_repeats_for_negative_scroll_lines() {
let grid_point = Point::new(0, 0);
- let scroll_event = ScrollWheelEvent {
+ let scroll_event = ScrollEvent {
delta: ScrollDelta::Lines(point(0., -1.)),
touch_phase: TouchPhase::Moved,
..Default::default()
@@ -123,7 +123,7 @@ mod tests {
fn scroll_report_repeats_for_positive_scroll_lines() {
let grid_point = Point::new(0, 0);
- let scroll_event = ScrollWheelEvent {
+ let scroll_event = ScrollEvent {
delta: ScrollDelta::Lines(point(0., 1.)),
touch_phase: TouchPhase::Moved,
..Default::default()
diff --git a/crates/terminal/src/terminal.rs b/crates/terminal/src/terminal.rs
index aee760ec582..141a9224f1c 100644
--- a/crates/terminal/src/terminal.rs
+++ b/crates/terminal/src/terminal.rs
@@ -56,7 +56,7 @@ pub use vte::ansi::{Color, NamedColor, Rgb};
use gpui::{
App, AppContext as _, BackgroundExecutor, Bounds, ClipboardItem, Context, EventEmitter, Hsla,
Keystroke, Modifiers, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, Pixels,
- Point as GpuiPoint, Rgba, ScrollWheelEvent, Size, Task, TouchPhase, Window, actions, black, px,
+ Point as GpuiPoint, Rgba, ScrollEvent, Size, Task, TouchPhase, Window, actions, black, px,
};
#[cfg(not(windows))]
@@ -2890,12 +2890,7 @@ impl Terminal {
}
///Scroll the terminal
- pub fn scroll_wheel(
- &mut self,
- e: &ScrollWheelEvent,
- scroll_multiplier: f32,
- mode: MouseInputMode,
- ) {
+ pub fn scroll_wheel(&mut self, e: &ScrollEvent, scroll_multiplier: f32, mode: MouseInputMode) {
let mouse_mode = self.mouse_mode(e.shift, mode);
let scroll_multiplier = if mouse_mode { 1. } else { scroll_multiplier };
@@ -2934,11 +2929,7 @@ impl Terminal {
self.schedule_find_hyperlink(window.modifiers(), window.mouse_position(), cx);
}
- fn determine_scroll_lines(
- &mut self,
- e: &ScrollWheelEvent,
- scroll_multiplier: f32,
- ) -> Option<i32> {
+ fn determine_scroll_lines(&mut self, e: &ScrollEvent, scroll_multiplier: f32) -> Option<i32> {
let line_height = self.last_content.terminal_bounds.line_height;
match e.touch_phase {
/* Reset scroll state on started */
@@ -4154,7 +4145,7 @@ mod tests {
assert!(terminal.last_content.mode.intersects(Modes::MOUSE_MODE));
assert_eq!(display_offset(&terminal.term.lock()), 0);
- let scroll_event = ScrollWheelEvent {
+ let scroll_event = ScrollEvent {
position: point(px(50.0), px(10.0)),
delta: ScrollDelta::Lines(point(0.0, 1.0)),
..Default::default()
@@ -4183,7 +4174,7 @@ mod tests {
);
assert_eq!(display_offset(&terminal.term.lock()), 0);
- let scroll_event = ScrollWheelEvent {
+ let scroll_event = ScrollEvent {
position: point(px(50.0), px(10.0)),
delta: ScrollDelta::Lines(point(0.0, 1.0)),
..Default::default()
@@ -6216,7 +6207,7 @@ mod tests {
mod perf {
use super::{super::*, init_terminal_test_with_window};
- use gpui::{ScrollDelta, ScrollWheelEvent, TestAppContext, VisualContext, point};
+ use gpui::{ScrollDelta, ScrollEvent, TestAppContext, VisualContext, point};
use util::default;
use util_macros::perf;
@@ -6242,7 +6233,7 @@ mod tests {
);
terminal.scroll_wheel(
- &ScrollWheelEvent {
+ &ScrollEvent {
position,
delta: ScrollDelta::Lines(GpuiPoint::new(0.0, lines as f32)),
..default()
diff --git a/crates/terminal_view/src/terminal_element.rs b/crates/terminal_view/src/terminal_element.rs
index 7dc48187595..27069343fa7 100644
--- a/crates/terminal_view/src/terminal_element.rs
+++ b/crates/terminal_view/src/terminal_element.rs
@@ -1060,7 +1060,7 @@ impl TerminalElement {
}
if content_mode.is_scrollable() {
- self.interactivity.on_scroll_wheel({
+ self.interactivity.on_scroll({
let terminal_view = self.terminal_view.downgrade();
move |e, window, cx| {
terminal_view
diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rs
index 0cd612f809c..c1e5105e101 100644
--- a/crates/terminal_view/src/terminal_view.rs
+++ b/crates/terminal_view/src/terminal_view.rs
@@ -11,8 +11,8 @@ use editor::{
use gpui::{
Action, AnyElement, App, ClipboardEntry, Corners, DismissEvent, Entity, EventEmitter,
ExternalPaths, FocusHandle, Focusable, Font, KeyContext, KeyDownEvent, Keystroke, MouseButton,
- MouseDownEvent, Pixels, Point as GpuiPoint, Rems, Render, ScrollWheelEvent, Styled,
- Subscription, Task, TaskExt, WeakEntity, actions, anchored, deferred, div,
+ MouseDownEvent, Pixels, Point as GpuiPoint, Rems, Render, ScrollEvent, Styled, Subscription,
+ Task, TaskExt, WeakEntity, actions, anchored, deferred, div,
};
use menu;
use persistence::TerminalDb;
@@ -768,7 +768,7 @@ impl TerminalView {
max_scroll_top_in_lines as f32 * line_height
}
- fn scroll_wheel(&mut self, event: &ScrollWheelEvent, cx: &mut Context<Self>) {
+ fn scroll_wheel(&mut self, event: &ScrollEvent, cx: &mut Context<Self>) {
let terminal_content = self.terminal.read(cx).last_content();
if self.block_below_cursor.is_some() && terminal_content.display_offset == 0 {
diff --git a/crates/ui/src/components/scrollbar.rs b/crates/ui/src/components/scrollbar.rs
index d20a30e8cdc..32010ce158a 100644
--- a/crates/ui/src/components/scrollbar.rs
+++ b/crates/ui/src/components/scrollbar.rs
@@ -6,8 +6,8 @@ use gpui::{
ContentMask, Context, Corners, CursorStyle, DispatchPhase, Div, Edges, Element, ElementId,
Entity, EntityId, GlobalElementId, Hitbox, HitboxBehavior, Hsla, InteractiveElement,
IntoElement, IsZero, LayoutId, ListState, MouseButton, MouseDownEvent, MouseMoveEvent,
- MouseUpEvent, ParentElement, Pixels, Point, Position, Render, ScrollHandle, ScrollWheelEvent,
- Size, Stateful, StatefulInteractiveElement, Style, StyleRefinement, Styled, Task,
+ MouseUpEvent, ParentElement, Pixels, Point, Position, Render, ScrollEvent, ScrollHandle, Size,
+ Stateful, StatefulInteractiveElement, Style, StyleRefinement, Styled, Task,
UniformListDecoration, UniformListScrollHandle, Window, ease_in_out, fill,
prelude::FluentBuilder as _, px, quad, relative, size,
};
@@ -1666,7 +1666,7 @@ impl<T: ScrollableHandle> Element for ScrollbarElement<T> {
window.on_mouse_event({
let state = self.state.clone();
- move |event: &ScrollWheelEvent, phase, window, cx| {
+ move |event: &ScrollEvent, phase, window, cx| {
state.update(cx, |state, cx| {
if phase.capture() && state.parent_hovered(window) {
state.update_hovered_thumb(&event.position, window, cx)
diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs
index 25771a8ee1f..70e7c500012 100644
--- a/crates/workspace/src/pane.rs
+++ b/crates/workspace/src/pane.rs
@@ -3687,7 +3687,7 @@ impl Pane {
.overflow_x_scroll()
.w_full()
.track_scroll(&self.tab_bar_scroll_handle)
- .on_scroll_wheel(cx.listener(|this, _, _, _| {
+ .on_scroll(cx.listener(|this, _, _, _| {
this.suppress_scroll = true;
}))
.children(unpinned_tabs)
diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs
index 960f4d692c5..ce57d405111 100644
--- a/crates/zed/src/zed.rs
+++ b/crates/zed/src/zed.rs
@@ -4879,7 +4879,7 @@ mod tests {
let initial_font_size =
cx.update(|_, cx| ThemeSettings::get_global(cx).buffer_font_size(cx).as_f32());
- cx.simulate_event(gpui::ScrollWheelEvent {
+ cx.simulate_event(gpui::ScrollEvent {
position: mouse_position,
delta: gpui::ScrollDelta::Pixels(point(px(0.), px(1.))),
modifiers: event_modifiers,
@@ -4907,7 +4907,7 @@ mod tests {
window.draw(cx).clear(cx);
});
- cx.simulate_event(gpui::ScrollWheelEvent {
+ cx.simulate_event(gpui::ScrollEvent {
position: mouse_position,
delta: gpui::ScrollDelta::Pixels(point(px(0.), px(1.))),
modifiers: event_modifiers,
@@ -4926,7 +4926,7 @@ mod tests {
window.draw(cx).clear(cx);
});
- cx.simulate_event(gpui::ScrollWheelEvent {
+ cx.simulate_event(gpui::ScrollEvent {
position: mouse_position,
delta: gpui::ScrollDelta::Pixels(point(px(0.), px(-1.))),
modifiers: event_modifiers,
@@ -4957,7 +4957,7 @@ mod tests {
window.draw(cx).clear(cx);
});
- cx.simulate_event(gpui::ScrollWheelEvent {
+ cx.simulate_event(gpui::ScrollEvent {
position: mouse_position,
delta: gpui::ScrollDelta::Pixels(point(px(0.), px(1.))),
modifiers: event_modifiers,