Skip to content

Commit

Permalink
Fix the sign of x wheel events in OSX to be inline with "natural scro…
Browse files Browse the repository at this point in the history
…lling" preference.

- The VM should generate positive deltaX for Left to Right trackpad motion
- The VM should generate positive deltaY for Bottom to Up trackpad motion

For historical reasons, if VM does not send mouse wheel events, but fake keyboard arrow events, then:

- The VM should generate a left arrow key for Left to Right trackpad motion
- The VM should generate a bottom arrow key for Bottom to Up trackpad motion

Not that the preferred direction preference of OSX is taken into account by the VM
See https://developer.apple.com/documentation/appkit/nsevent/1525151-isdirectioninvertedfromdevice
Above description is for "natural scrolling" preference (the trackpad does drag the screen contents).
It will be inverted if the preference is unset (the trackpad does drag the scroll bar).

Note that the `isFlipped` method of the Cocoa/Quartz view presumably ha an impact on sign of vertical motions
See https://developer.apple.com/documentation/appkit/nsview/1483532-isflipped
OpenSmalltalk VM does use isFlipped YES.
  • Loading branch information
nicolas-cellier-aka-nice committed Dec 31, 2019
1 parent 9f4fae8 commit f219b72
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions platforms/iOS/vm/OSX/sqSqueakOSXApplication+events.m
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,10 @@ - (void) recordWheelEvent:(NSEvent *) theEvent fromView: (NSView <sqSqueakOSXVie
evt.type = EventTypeMouseWheel;
evt.timeStamp = ioMSecs();

evt.x = prevXDelta;
evt.y = prevYDelta;
/* Note: if natural scrolling preference is enabled, the VM should generate a positive x for motion from left to right
* and a positive y for a motion from bottom to up */
evt.x = - prevXDelta; /* we have to change the x convention, presumably because natural is inverted */
evt.y = + prevYDelta; /* but not that of y presumably because the view isFlipped (see implementation of isFlipped) */

prevXDelta = 0;
prevYDelta = 0;
Expand Down

0 comments on commit f219b72

Please sign in to comment.