From a0c10abe80c94e53b189ea8f6fff534db853a89f Mon Sep 17 00:00:00 2001 From: Thorsten Ball Date: Fri, 2 Feb 2024 09:31:12 +0100 Subject: [PATCH] Revert "scrolling: use display scale factor on pixel scroll" This reverts commit 32d490b16c734b903c924154fcd8f8f1c8c5854a. --- crates/gpui/src/interactive.rs | 2 +- crates/gpui/src/platform/mac/events.rs | 3 +-- crates/gpui/src/platform/mac/platform.rs | 2 +- crates/gpui/src/platform/mac/window.rs | 7 ++----- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/crates/gpui/src/interactive.rs b/crates/gpui/src/interactive.rs index 0be2bb8ed8..1bc32717c4 100644 --- a/crates/gpui/src/interactive.rs +++ b/crates/gpui/src/interactive.rs @@ -285,10 +285,10 @@ impl ScrollDelta { ScrollDelta::Lines(delta) => point(line_height * delta.x, line_height * delta.y), } } + /// Combines two scroll deltas into one. pub fn coalesce(self, other: ScrollDelta) -> ScrollDelta { match (self, other) { - // second time (ScrollDelta::Pixels(px_a), ScrollDelta::Pixels(px_b)) => { ScrollDelta::Pixels(px_a + px_b) } diff --git a/crates/gpui/src/platform/mac/events.rs b/crates/gpui/src/platform/mac/events.rs index cf7a2bae3b..4653ce89b4 100644 --- a/crates/gpui/src/platform/mac/events.rs +++ b/crates/gpui/src/platform/mac/events.rs @@ -86,7 +86,6 @@ impl PlatformInput { pub(crate) unsafe fn from_native( native_event: id, window_height: Option, - scale_factor: Option, ) -> Option { let event_type = native_event.eventType(); @@ -175,7 +174,7 @@ impl PlatformInput { ); let delta = if native_event.hasPreciseScrollingDeltas() == YES { - ScrollDelta::Pixels(raw_data.map(|p| px(p * scale_factor.unwrap_or(2.)))) + ScrollDelta::Pixels(raw_data.map(px)) } else { ScrollDelta::Lines(raw_data) }; diff --git a/crates/gpui/src/platform/mac/platform.rs b/crates/gpui/src/platform/mac/platform.rs index 85122df92b..76c8ec7e6e 100644 --- a/crates/gpui/src/platform/mac/platform.rs +++ b/crates/gpui/src/platform/mac/platform.rs @@ -981,7 +981,7 @@ unsafe fn get_mac_platform(object: &mut Object) -> &MacPlatform { extern "C" fn send_event(this: &mut Object, _sel: Sel, native_event: id) { unsafe { - if let Some(event) = PlatformInput::from_native(native_event, None, None) { + if let Some(event) = PlatformInput::from_native(native_event, None) { let platform = get_mac_platform(this); let mut lock = platform.0.lock(); if let Some(mut callback) = lock.event.take() { diff --git a/crates/gpui/src/platform/mac/window.rs b/crates/gpui/src/platform/mac/window.rs index 62f8601d00..ce25c4d6eb 100644 --- a/crates/gpui/src/platform/mac/window.rs +++ b/crates/gpui/src/platform/mac/window.rs @@ -1102,7 +1102,7 @@ extern "C" fn handle_key_event(this: &Object, native_event: id, key_equivalent: let mut lock = window_state.as_ref().lock(); let window_height = lock.content_size().height; - let event = unsafe { PlatformInput::from_native(native_event, Some(window_height), None) }; + let event = unsafe { PlatformInput::from_native(native_event, Some(window_height)) }; if let Some(PlatformInput::KeyDown(event)) = event { // For certain keystrokes, macOS will first dispatch a "key equivalent" event. @@ -1195,10 +1195,7 @@ extern "C" fn handle_view_event(this: &Object, _: Sel, native_event: id) { let is_active = unsafe { lock.native_window.isKeyWindow() == YES }; let window_height = lock.content_size().height; - let scale_factor = lock.scale_factor(); - let event = unsafe { - PlatformInput::from_native(native_event, Some(window_height), Some(scale_factor)) - }; + let event = unsafe { PlatformInput::from_native(native_event, Some(window_height)) }; if let Some(mut event) = event { match &mut event {