Fix T45167: OS X inertial scrolling can lead to unexpected zooming.
Differential Revision: https://developer.blender.org/D1539
This commit is contained in:
@@ -297,6 +297,8 @@ protected:
|
|||||||
*/
|
*/
|
||||||
GHOST_TInt32 m_cursorDelta_x, m_cursorDelta_y;
|
GHOST_TInt32 m_cursorDelta_x, m_cursorDelta_y;
|
||||||
|
|
||||||
|
/** Temporarily ignore momentum scroll events */
|
||||||
|
bool m_ignoreMomentumScroll;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __GHOST_SYSTEMCOCOA_H__
|
#endif // __GHOST_SYSTEMCOCOA_H__
|
||||||
|
@@ -374,6 +374,7 @@ GHOST_SystemCocoa::GHOST_SystemCocoa()
|
|||||||
rstring = NULL;
|
rstring = NULL;
|
||||||
|
|
||||||
m_ignoreWindowSizedMessages = false;
|
m_ignoreWindowSizedMessages = false;
|
||||||
|
m_ignoreMomentumScroll = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GHOST_SystemCocoa::~GHOST_SystemCocoa()
|
GHOST_SystemCocoa::~GHOST_SystemCocoa()
|
||||||
@@ -1391,19 +1392,33 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
|
|||||||
|
|
||||||
case NSScrollWheel:
|
case NSScrollWheel:
|
||||||
{
|
{
|
||||||
NSEventPhase momentum = NSEventPhaseNone;
|
NSEventPhase momentumPhase = NSEventPhaseNone;
|
||||||
NSEventPhase phase = NSEventPhaseNone;
|
NSEventPhase phase = NSEventPhaseNone;
|
||||||
bool hasMultiTouch = false;
|
bool hasMultiTouch = false;
|
||||||
|
|
||||||
if ([event respondsToSelector:@selector(momentumPhase)])
|
if ([event respondsToSelector:@selector(momentumPhase)])
|
||||||
momentum = [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)])
|
if ([event respondsToSelector:@selector(hasPreciseScrollingDeltas)])
|
||||||
hasMultiTouch = [event hasPreciseScrollingDeltas];
|
hasMultiTouch = [event hasPreciseScrollingDeltas];
|
||||||
|
|
||||||
|
/* 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 (m_ignoreMomentumScroll)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_ignoreMomentumScroll = 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 && momentum == NSEventPhaseNone) {
|
if (!hasMultiTouch && momentumPhase == NSEventPhaseNone) {
|
||||||
GHOST_TInt32 delta;
|
GHOST_TInt32 delta;
|
||||||
|
|
||||||
double deltaF = [event deltaY];
|
double deltaF = [event deltaY];
|
||||||
@@ -1426,7 +1441,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
|
|||||||
dy = [event scrollingDeltaY];
|
dy = [event scrollingDeltaY];
|
||||||
|
|
||||||
/* however, wacom tablet (intuos5) needs old deltas, it then has momentum and phase at zero */
|
/* however, wacom tablet (intuos5) needs old deltas, it then has momentum and phase at zero */
|
||||||
if (phase == NSEventPhaseNone && momentum == NSEventPhaseNone) {
|
if (phase == NSEventPhaseNone && momentumPhase == NSEventPhaseNone) {
|
||||||
dx = [event deltaX];
|
dx = [event deltaX];
|
||||||
dy = [event deltaY];
|
dy = [event deltaY];
|
||||||
}
|
}
|
||||||
@@ -1561,6 +1576,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
|
|||||||
pushEvent( new GHOST_EventKey([event timestamp] * 1000, GHOST_kEventKeyUp, window, keyCode, 0, NULL) );
|
pushEvent( new GHOST_EventKey([event timestamp] * 1000, GHOST_kEventKeyUp, window, keyCode, 0, NULL) );
|
||||||
//printf("Key up rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c utf8=%s\n",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii, utf8_buf);
|
//printf("Key up rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c utf8=%s\n",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii, utf8_buf);
|
||||||
}
|
}
|
||||||
|
m_ignoreMomentumScroll = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NSFlagsChanged:
|
case NSFlagsChanged:
|
||||||
@@ -1580,6 +1596,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_modifierMask = modifiers;
|
m_modifierMask = modifiers;
|
||||||
|
m_ignoreMomentumScroll = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Reference in New Issue
Block a user