From 99c8bc55679d362f3da8070a86a4548c3de22037 Mon Sep 17 00:00:00 2001 From: Ferdinand Schober Date: Wed, 29 Oct 2025 16:18:46 +0100 Subject: [PATCH] macsos: use ScrollEventUnit::LINE for mousewheel (#337) --- input-emulation/src/macos.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/input-emulation/src/macos.rs b/input-emulation/src/macos.rs index 0ac3dbe..1acb60e 100644 --- a/input-emulation/src/macos.rs +++ b/input-emulation/src/macos.rs @@ -343,9 +343,10 @@ impl Emulation for MacOSEmulation { event.post(CGEventTapLocation::HID); } PointerEvent::AxisDiscrete120 { axis, value } => { + const LINES_PER_STEP: i32 = 3; let (count, wheel1, wheel2, wheel3) = match axis { - 0 => (1, value, 0, 0), // 0 = vertical => 1 scroll wheel device (y axis) - 1 => (2, 0, value, 0), // 1 = horizontal => 2 scroll wheel devices (y, x) -> (0, x) + 0 => (1, value / (120 / LINES_PER_STEP), 0, 0), // 0 = vertical => 1 scroll wheel device (y axis) + 1 => (2, 0, value / (120 / LINES_PER_STEP), 0), // 1 = horizontal => 2 scroll wheel devices (y, x) -> (0, x) _ => { log::warn!("invalid scroll event: {axis}, {value}"); return Ok(()); @@ -353,7 +354,7 @@ impl Emulation for MacOSEmulation { }; let event = match CGEvent::new_scroll_event( self.event_source.clone(), - ScrollEventUnit::PIXEL, + ScrollEventUnit::LINE, count, wheel1, wheel2,