From f7b3fe466e7c443b4ec60901899fc538b66c0cc1 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 13 Jul 2024 16:35:09 -0400 Subject: [PATCH] MacOS: Fix mouse wheel scroll speed This just happens to be the factor that results in one tick of a conventional mouse wheel being a change of 1.0 "lines" as on other platforms (at least for me, hopefully everywhere). Moving a wheel quickly does result in quite a lot of acceleration on MacOS though, so more refinement might be needed here for consistent event handling across platforms. --- src/mac.m | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/mac.m b/src/mac.m index abbbf34c..727f1424 100644 --- a/src/mac.m +++ b/src/mac.m @@ -630,10 +630,16 @@ - (void)otherMouseUp:(NSEvent*)event - (void)scrollWheel:(NSEvent*)event { - const NSPoint wloc = [self eventLocation:event]; - const NSPoint rloc = [NSEvent mouseLocation]; - const double dx = -[event scrollingDeltaX]; - const double dy = [event scrollingDeltaY]; + const NSPoint wloc = [self eventLocation:event]; + const NSPoint rloc = [NSEvent mouseLocation]; + + double dx = -[event scrollingDeltaX]; + double dy = [event scrollingDeltaY]; + if (![event hasPreciseScrollingDeltas]) { + dx *= 10.0; + dy *= 10.0; + } + const PuglScrollDirection dir = ((dx == 0.0 && dy > 0.0) ? PUGL_SCROLL_UP @@ -653,7 +659,7 @@ - (void)scrollWheel:(NSEvent*)event rloc.x, [[NSScreen mainScreen] frame].size.height - rloc.y, getModifiers(event), - [event hasPreciseScrollingDeltas] ? PUGL_SCROLL_SMOOTH : dir, + dir, dx, dy, };