Skip to content

Commit

Permalink
MacOS: Fix mouse wheel scroll speed
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
drobilla committed Jul 13, 2024
1 parent d595909 commit f7b3fe4
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/mac.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
};
Expand Down

0 comments on commit f7b3fe4

Please sign in to comment.