From 1566858d709ce7c15193ba926ca58ac73bf15e50 Mon Sep 17 00:00:00 2001 From: Sebastien Pouliot Date: Thu, 7 Nov 2024 20:04:45 -0500 Subject: [PATCH] fix(macOS): adjust scrollwheel speed for normal/PC mouses --- .../UnoNativeMac/UnoNativeMac/UNOWindow.m | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Uno.UI.Runtime.Skia.MacOS/UnoNativeMac/UnoNativeMac/UNOWindow.m b/src/Uno.UI.Runtime.Skia.MacOS/UnoNativeMac/UnoNativeMac/UNOWindow.m index 7a72f4ebfdcc..3b1e6cb9ca7c 100644 --- a/src/Uno.UI.Runtime.Skia.MacOS/UnoNativeMac/UnoNativeMac/UNOWindow.m +++ b/src/Uno.UI.Runtime.Skia.MacOS/UnoNativeMac/UnoNativeMac/UNOWindow.m @@ -790,8 +790,15 @@ - (void)sendEvent:(NSEvent *)event { // scrollwheel if (mouse == MouseEventsScrollWheel) { // do not call if not in the scrollwheel event -> *** Assertion failure in -[NSEvent scrollingDeltaX], NSEvent.m:2202 - data.scrollingDeltaX = (int32_t)event.scrollingDeltaX; - data.scrollingDeltaY = (int32_t)event.scrollingDeltaY; + + // trackpad / magic mouse sends about 10x more events than a _normal_ (PC) mouse + // this is often refered as a line scroll versus a pixel scroll + double factor = event.hasPreciseScrollingDeltas ? 1.0 : 10.0; + data.scrollingDeltaX = (int32_t)(event.scrollingDeltaX * factor); + data.scrollingDeltaY = (int32_t)(event.scrollingDeltaY * factor); +#if DEBUG_MOUSE // very noisy + NSLog(@"NSEventTypeMouse*: %@ %g %g delta %g %g %s scrollingDelta %d %d", event, data.x, data.y, event.deltaX, event.deltaY, event.hasPreciseScrollingDeltas ? "precise" : "non-precise", data.scrollingDeltaX, data.scrollingDeltaY); +#endif } // other