Skip to content

Commit

Permalink
Merge pull request #18737 from unoplatform/dev/spouliot/gh16400
Browse files Browse the repository at this point in the history
fix(macOS): adjust scrollwheel speed for normal/PC mouses
  • Loading branch information
spouliot authored Nov 8, 2024
2 parents e621fe4 + 1566858 commit 1ee3603
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1ee3603

Please sign in to comment.