Skip to content

Commit

Permalink
Convert OSX point units into scrolling units
Browse files Browse the repository at this point in the history
Set the limit to 20 scrolling units to restrain the flow of events delivered to image
That's about 7 points (1/10 inch), not exactly the smoothest.
But if we want smoother scroll, we have to accelerate event handling at image side first.

The threshold might become a parameter, but for now YAGNI.

Note: the scrolling unit of 120 units per mouse wheel notch comes from moz.dev.
The fact that we convert a single notch to 3 lines is a Squeak convention
See #41
  • Loading branch information
nicolas-cellier-aka-nice committed Dec 27, 2019
1 parent 92fa6f8 commit 9d26c97
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions platforms/iOS/vm/OSX/sqSqueakOSXApplication+events.m
Expand Up @@ -270,12 +270,19 @@ - (void) recordWheelEvent:(NSEvent *) theEvent fromView: (NSView <sqSqueakOSXVie
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7)
CGFloat x = [theEvent scrollingDeltaX];
CGFloat y = [theEvent scrollingDeltaY];
/* Convert event units into scrolling units
Assume that 1 event unit corresponds to a single wheel mouse notch
A single notch evaluates to 120 scrolling units */
float xDelta = x * 120;
float yDelta = y * 120;
if ([theEvent respondsToSelector:@selector(hasPreciseScrollingDeltas)]) {
if ([theEvent hasPreciseScrollingDeltas]) {
xDelta = x;
yDelta = y;
/* Note: in case of precise scrolling x,y are given in points
Assume that 120 scrolling units corresponds to 3 lines delta
that is 40 points for a 13.3 point line grid
hence the factor 3 */
xDelta = x * 3;
yDelta = y * 3;
}
}
#else
Expand All @@ -295,7 +302,7 @@ - (void) recordWheelEvent:(NSEvent *) theEvent fromView: (NSView <sqSqueakOSXVie
prevYTime = now;
}
if (sendWheelEvents) {
float limit = 10;
float limit = 20;
if (-limit < prevXDelta && prevXDelta < limit && -limit < prevYDelta && prevYDelta < limit ) return;
sqMouseEvent evt;
memset(&evt,0,sizeof(evt));
Expand Down

0 comments on commit 9d26c97

Please sign in to comment.