aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2024-07-13 16:35:09 -0400
committerDavid Robillard <d@drobilla.net>2024-07-13 16:38:39 -0400
commitf7b3fe466e7c443b4ec60901899fc538b66c0cc1 (patch)
treeb26e6d349869c0ff0e2ba2a89e0bce674af58edf
parentd5959095d8ea8e3adfa661f622d7f1d2c2771c49 (diff)
downloadpugl-f7b3fe466e7c443b4ec60901899fc538b66c0cc1.tar.gz
pugl-f7b3fe466e7c443b4ec60901899fc538b66c0cc1.tar.bz2
pugl-f7b3fe466e7c443b4ec60901899fc538b66c0cc1.zip
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.
-rw-r--r--src/mac.m16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/mac.m b/src/mac.m
index abbbf34..727f142 100644
--- a/src/mac.m
+++ b/src/mac.m
@@ -630,10 +630,16 @@ handleCrossing(PuglWrapperView* view, NSEvent* event, const PuglEventType type)
- (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 @@ handleCrossing(PuglWrapperView* view, NSEvent* event, const PuglEventType type)
rloc.x,
[[NSScreen mainScreen] frame].size.height - rloc.y,
getModifiers(event),
- [event hasPreciseScrollingDeltas] ? PUGL_SCROLL_SMOOTH : dir,
+ dir,
dx,
dy,
};