Fix T46341: OS X trackpad and magic mouse gestures not working with 10.11 SDK.

Differential Revision: https://developer.blender.org/D1539
This commit is contained in:
Brecht Van Lommel 2015-10-04 18:00:20 +02:00
parent f42ae6c569
commit a8dd0af8cf
Notes: blender-bot 2023-02-14 08:34:42 +01:00
Referenced by issue #47153, Scroll wheel zoom in view3d fails on OS X
Referenced by issue #46341, OS X trackpad and magic mouse gestures not working
3 changed files with 14 additions and 34 deletions

View File

@ -297,9 +297,6 @@ protected:
*/
GHOST_TInt32 m_cursorDelta_x, m_cursorDelta_y;
/** Multitouch trackpad availability */
bool m_hasMultiTouchTrackpad;
};
#endif // __GHOST_SYSTEMCOCOA_H__

View File

@ -370,8 +370,6 @@ GHOST_SystemCocoa::GHOST_SystemCocoa()
rstring = (char*)malloc( len );
sysctl( mib, 2, rstring, &len, NULL, 0 );
m_hasMultiTouchTrackpad = false;
free( rstring );
rstring = NULL;
@ -1223,10 +1221,10 @@ bool GHOST_SystemCocoa::handleTabletEvent(void *eventPtr)
NSEvent *event = (NSEvent *)eventPtr;
switch ([event subtype]) {
case NX_SUBTYPE_TABLET_POINT:
case NSTabletPointEventSubtype:
handleTabletEvent(eventPtr, NSTabletPoint);
return true;
case NX_SUBTYPE_TABLET_PROXIMITY:
case NSTabletProximityEventSubtype:
handleTabletEvent(eventPtr, NSTabletProximity);
return true;
default:
@ -1390,25 +1388,22 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
}
}
break;
/* these events only happen on swiping trackpads or tablets */
/* warning: using tablet + trackpad at same time frustrates this static variable */
case NSEventTypeBeginGesture:
m_hasMultiTouchTrackpad = 1;
break;
case NSEventTypeEndGesture:
m_hasMultiTouchTrackpad = 0;
break;
case NSScrollWheel:
{
int *momentum = NULL;
NSEventPhase momentum = NSEventPhaseNone;
NSEventPhase phase = NSEventPhaseNone;
bool hasMultiTouch = false;
if ([event respondsToSelector:@selector(momentumPhase)])
momentum = (int *)[event momentumPhase];
momentum = [event momentumPhase];
if ([event respondsToSelector:@selector(phase)])
phase = [event phase];
if ([event respondsToSelector:@selector(hasPreciseScrollingDeltas)])
hasMultiTouch = [event hasPreciseScrollingDeltas];
/* standard scrollwheel case, if no swiping happened, and no momentum (kinetic scroll) works */
if (!m_hasMultiTouchTrackpad && momentum == NULL) {
if (!hasMultiTouch && momentum == NSEventPhaseNone) {
GHOST_TInt32 delta;
double deltaF = [event deltaY];
@ -1424,16 +1419,14 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
GHOST_TInt32 x, y;
double dx;
double dy;
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
int phase = [event phase];
/* with 10.7 nice scrolling deltas are supported */
dx = [event scrollingDeltaX];
dy = [event scrollingDeltaY];
/* however, wacom tablet (intuos5) needs old deltas, it then has momentum and phase at zero */
if (phase == 0 && momentum==NULL) {
if (phase == NSEventPhaseNone && momentum == NSEventPhaseNone) {
dx = [event deltaX];
dy = [event deltaY];
}

View File

@ -393,16 +393,6 @@ enum {
systemCocoa->handleMouseEvent(event);
}
- (void)beginGestureWithEvent:(NSEvent *)event
{
systemCocoa->handleMouseEvent(event);
}
- (void)endGestureWithEvent:(NSEvent *)event
{
systemCocoa->handleMouseEvent(event);
}
- (void)tabletPoint:(NSEvent *)event
{
systemCocoa->handleTabletEvent(event,[event type]);