forked from bartvdbraak/blender
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
This commit is contained in:
parent
6a593aba44
commit
88770bed7c
@ -299,6 +299,8 @@ protected:
|
|||||||
|
|
||||||
/** Temporarily ignore momentum scroll events */
|
/** Temporarily ignore momentum scroll events */
|
||||||
bool m_ignoreMomentumScroll;
|
bool m_ignoreMomentumScroll;
|
||||||
|
/** Is the scroll wheel event generated by a multitouch trackpad or mouse? */
|
||||||
|
bool m_multiTouchScroll;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __GHOST_SYSTEMCOCOA_H__
|
#endif // __GHOST_SYSTEMCOCOA_H__
|
||||||
|
@ -375,6 +375,7 @@ GHOST_SystemCocoa::GHOST_SystemCocoa()
|
|||||||
|
|
||||||
m_ignoreWindowSizedMessages = false;
|
m_ignoreWindowSizedMessages = false;
|
||||||
m_ignoreMomentumScroll = false;
|
m_ignoreMomentumScroll = false;
|
||||||
|
m_multiTouchScroll = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GHOST_SystemCocoa::~GHOST_SystemCocoa()
|
GHOST_SystemCocoa::~GHOST_SystemCocoa()
|
||||||
@ -1392,31 +1393,34 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
|
|||||||
{
|
{
|
||||||
NSEventPhase momentumPhase = NSEventPhaseNone;
|
NSEventPhase momentumPhase = NSEventPhaseNone;
|
||||||
NSEventPhase phase = NSEventPhaseNone;
|
NSEventPhase phase = NSEventPhaseNone;
|
||||||
bool hasMultiTouch = false;
|
|
||||||
|
|
||||||
if ([event respondsToSelector:@selector(momentumPhase)])
|
if ([event respondsToSelector:@selector(momentumPhase)])
|
||||||
momentumPhase = [event momentumPhase];
|
momentumPhase = [event momentumPhase];
|
||||||
if ([event respondsToSelector:@selector(phase)])
|
if ([event respondsToSelector:@selector(phase)])
|
||||||
phase = [event phase];
|
phase = [event phase];
|
||||||
if ([event respondsToSelector:@selector(hasPreciseScrollingDeltas)])
|
|
||||||
hasMultiTouch = [event hasPreciseScrollingDeltas] && [event subtype] != NSMouseEventSubtype;
|
|
||||||
|
|
||||||
/* when pressing a key while momentum scrolling continues after
|
/* when pressing a key while momentum scrolling continues after
|
||||||
* lifting fingers off the trackpad, the action can unexpectedly
|
* lifting fingers off the trackpad, the action can unexpectedly
|
||||||
* change from e.g. scrolling to zooming. this works around the
|
* change from e.g. scrolling to zooming. this works around the
|
||||||
* issue by ignoring momentum scroll after a key press */
|
* issue by ignoring momentum scroll after a key press */
|
||||||
if (momentumPhase)
|
if (momentumPhase) {
|
||||||
{
|
|
||||||
if (m_ignoreMomentumScroll)
|
if (m_ignoreMomentumScroll)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
m_ignoreMomentumScroll = false;
|
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 */
|
/* 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;
|
GHOST_TInt32 delta;
|
||||||
|
|
||||||
double deltaF = [event deltaY];
|
double deltaF = [event deltaY];
|
||||||
|
Loading…
Reference in New Issue
Block a user