Fix T46341: OS X trackpad and magic mouse gestures not working with 10.11 SDK.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Sun, 4 Oct 2015 16:00:20 +0000 (18:00 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Sat, 10 Oct 2015 12:00:02 +0000 (14:00 +0200)
Differential Revision: https://developer.blender.org/D1539

intern/ghost/intern/GHOST_SystemCocoa.h
intern/ghost/intern/GHOST_SystemCocoa.mm
intern/ghost/intern/GHOST_WindowCocoa.mm

index 3d6b40ee54153970c64fdc28b6a11d16bc94bdd2..b49a7d8a0a3a53e0af6b14497e7bda5ac1e50072 100644 (file)
@@ -297,9 +297,6 @@ protected:
         */
        GHOST_TInt32 m_cursorDelta_x, m_cursorDelta_y;
        
-       /** Multitouch trackpad availability */
-       bool m_hasMultiTouchTrackpad;
-       
 };
 
 #endif // __GHOST_SYSTEMCOCOA_H__
index 37c2ac12315279f93e5d64fbfd215c17f4e2ff22..f5dfe5a175be51dc2e089224bf8be8359a88ea95 100644 (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];
                                        }
index 204d61de3dfc30a44a96fde1d0b50aedc37eacbe..38813e14a1b332a6235276ab718d9977c0ca2590 100644 (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]);