From 78ba1613d4b4323c3db4e786ae2c4ae19ba201d8 Mon Sep 17 00:00:00 2001 From: Nico Burns Date: Wed, 30 Oct 2024 23:45:34 +0700 Subject: [PATCH] Improve scrolling speed in servoshell. (#34063) Servo was previously using the inverse of the correct scale factor which could cause the scrolling speed to be 4x too slow on a machine with scale factor of 2.0 Signed-off-by: Nico Burns --- ports/servoshell/desktop/headed_window.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ports/servoshell/desktop/headed_window.rs b/ports/servoshell/desktop/headed_window.rs index 4c97d68a52a..70dc1d480e5 100644 --- a/ports/servoshell/desktop/headed_window.rs +++ b/ports/servoshell/desktop/headed_window.rs @@ -24,7 +24,7 @@ use servo::webrender_api::units::{DeviceIntPoint, DeviceIntRect, DeviceIntSize}; use servo::webrender_api::ScrollLocation; use servo::webrender_traits::RenderingContext; use surfman::{Connection, Context, Device, SurfaceType}; -use winit::dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize}; +use winit::dpi::{LogicalSize, PhysicalPosition, PhysicalSize}; use winit::event::{ElementState, KeyEvent, MouseButton, MouseScrollDelta, TouchPhase}; use winit::keyboard::{Key as LogicalKey, ModifiersState, NamedKey}; #[cfg(any(target_os = "linux", target_os = "windows"))] @@ -423,8 +423,8 @@ impl WindowPortsMethods for Window { (dx as f64, (dy * LINE_HEIGHT) as f64, WheelMode::DeltaLine) }, MouseScrollDelta::PixelDelta(position) => { - let position: LogicalPosition = - position.to_logical(self.device_hidpi_factor().get() as f64); + let scale_factor = self.device_hidpi_factor().inverse().get() as f64; + let position = position.to_logical(scale_factor); (position.x, position.y, WheelMode::DeltaPixel) }, };