From 9d26c9785d6fce76c69095f51c57309c65afa6e1 Mon Sep 17 00:00:00 2001 From: Nicolas Cellier Date: Fri, 27 Dec 2019 18:55:51 +0100 Subject: [PATCH] Convert OSX point units into scrolling units 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 https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/41 --- .../iOS/vm/OSX/sqSqueakOSXApplication+events.m | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/platforms/iOS/vm/OSX/sqSqueakOSXApplication+events.m b/platforms/iOS/vm/OSX/sqSqueakOSXApplication+events.m index 28808b9502..c079e8a313 100644 --- a/platforms/iOS/vm/OSX/sqSqueakOSXApplication+events.m +++ b/platforms/iOS/vm/OSX/sqSqueakOSXApplication+events.m @@ -270,12 +270,19 @@ - (void) recordWheelEvent:(NSEvent *) theEvent fromView: (NSView = 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 @@ -295,7 +302,7 @@ - (void) recordWheelEvent:(NSEvent *) theEvent fromView: (NSView