diff options
author | David Robillard <d@drobilla.net> | 2020-07-05 15:01:12 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-07-05 18:47:37 +0200 |
commit | 6c2460414082b989487abcad2ca2018a16ecdbd7 (patch) | |
tree | e1b2f29a01098b16483bf744088aca202f903ea0 /pugl/detail/mac.m | |
parent | 7d45962ccd6fabcb198599fead141de7cd578916 (diff) | |
download | pugl-6c2460414082b989487abcad2ca2018a16ecdbd7.tar.gz pugl-6c2460414082b989487abcad2ca2018a16ecdbd7.tar.bz2 pugl-6c2460414082b989487abcad2ca2018a16ecdbd7.zip |
Add scroll direction field
Diffstat (limited to 'pugl/detail/mac.m')
-rw-r--r-- | pugl/detail/mac.m | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/pugl/detail/mac.m b/pugl/detail/mac.m index 3e5a018..50c52c5 100644 --- a/pugl/detail/mac.m +++ b/pugl/detail/mac.m @@ -460,19 +460,32 @@ handleCrossing(PuglWrapperView* view, NSEvent* event, const PuglEventType type) - (void) scrollWheel:(NSEvent*)event { - const NSPoint wloc = [self eventLocation:event]; - const NSPoint rloc = [NSEvent mouseLocation]; - const PuglEventScroll ev = { - PUGL_SCROLL, - 0, - [event timestamp], - wloc.x, - wloc.y, - rloc.x, - [[NSScreen mainScreen] frame].size.height - rloc.y, - getModifiers(event), - [event scrollingDeltaX], - [event scrollingDeltaY], + const NSPoint wloc = [self eventLocation:event]; + const NSPoint rloc = [NSEvent mouseLocation]; + const double dx = [event scrollingDeltaX]; + const double dy = [event scrollingDeltaY]; + const PuglScrollDirection dir = + ((dx == 0.0 && dy > 0.0) + ? PUGL_SCROLL_UP + : ((dx == 0.0 && dy < 0.0) + ? PUGL_SCROLL_DOWN + : ((dy == 0.0 && dx > 0.0) + ? PUGL_SCROLL_RIGHT + : ((dy == 0.0 && dx < 0.0) ? PUGL_SCROLL_LEFT + : PUGL_SCROLL_SMOOTH)))); + + const PuglEventScroll ev = { + PUGL_SCROLL, + 0, + [event timestamp], + wloc.x, + wloc.y, + rloc.x, + [[NSScreen mainScreen] frame].size.height - rloc.y, + getModifiers(event), + [event hasPreciseScrollingDeltas] ? PUGL_SCROLL_SMOOTH : dir, + dx, + dy, }; puglDispatchEvent(puglview, (const PuglEvent*)&ev); |