diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2016-02-13 15:13:59 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2016-02-13 18:07:55 +0300 |
commit | 88770bed7c1125870f555978bb45ef837b70b9fb (patch) | |
tree | ebc7980a17be9acc183b528bd38d1b1b49dfc994 /intern/ghost | |
parent | 6a593aba44a799a0b7981b4fb2a699b1cdd44fd2 (diff) |
Fix T47393: mouse wheel scroll no longer zooms with mighty mouse on OS X.
Hopefully this is the last fix, using the method explained here:
https://forums.developer.apple.com/thread/31536
Diffstat (limited to 'intern/ghost')
-rw-r--r-- | intern/ghost/intern/GHOST_SystemCocoa.h | 2 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemCocoa.mm | 20 |
2 files changed, 14 insertions, 8 deletions
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.h b/intern/ghost/intern/GHOST_SystemCocoa.h index cfddd5b3781..b142c2f7194 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.h +++ b/intern/ghost/intern/GHOST_SystemCocoa.h @@ -299,6 +299,8 @@ protected: /** Temporarily ignore momentum scroll events */ bool m_ignoreMomentumScroll; + /** Is the scroll wheel event generated by a multitouch trackpad or mouse? */ + bool m_multiTouchScroll; }; #endif // __GHOST_SYSTEMCOCOA_H__ diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index 90f4557ad3a..73d501252e4 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -375,6 +375,7 @@ GHOST_SystemCocoa::GHOST_SystemCocoa() m_ignoreWindowSizedMessages = false; m_ignoreMomentumScroll = false; + m_multiTouchScroll = false; } GHOST_SystemCocoa::~GHOST_SystemCocoa() @@ -1392,31 +1393,34 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr) { NSEventPhase momentumPhase = NSEventPhaseNone; NSEventPhase phase = NSEventPhaseNone; - bool hasMultiTouch = false; if ([event respondsToSelector:@selector(momentumPhase)]) momentumPhase = [event momentumPhase]; if ([event respondsToSelector:@selector(phase)]) phase = [event phase]; - if ([event respondsToSelector:@selector(hasPreciseScrollingDeltas)]) - hasMultiTouch = [event hasPreciseScrollingDeltas] && [event subtype] != NSMouseEventSubtype; /* when pressing a key while momentum scrolling continues after * lifting fingers off the trackpad, the action can unexpectedly * change from e.g. scrolling to zooming. this works around the * issue by ignoring momentum scroll after a key press */ - if (momentumPhase) - { + if (momentumPhase) { if (m_ignoreMomentumScroll) break; } - else - { + else { m_ignoreMomentumScroll = false; } + /* we assume phases are only set for gestures from trackpad or magic + * mouse events. note that using tablet at the same time may not work + * since this is a static variable */ + if (phase == NSEventPhaseBegan) + m_multiTouchScroll = true; + else if (phase == NSEventPhaseEnded) + m_multiTouchScroll = false; + /* standard scrollwheel case, if no swiping happened, and no momentum (kinetic scroll) works */ - if (!hasMultiTouch && momentumPhase == NSEventPhaseNone) { + if (!m_multiTouchScroll && momentumPhase == NSEventPhaseNone) { GHOST_TInt32 delta; double deltaF = [event deltaY]; |