[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53604] trunk/blender/intern/ghost/intern/ GHOST_SystemCocoa.mm: With some help in irc (thanks erwin, markus!) and some googling, here's code

Ton Roosendaal ton at blender.org
Sun Jan 6 13:49:35 CET 2013


Revision: 53604
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53604
Author:   ton
Date:     2013-01-06 12:49:32 +0000 (Sun, 06 Jan 2013)
Log Message:
-----------
With some help in irc (thanks erwin, markus!) and some googling, here's code 
that compiles for OSX 10.6 for new momentumPhase usage.

Jens Verwiebe can give final blessings, I'm just copypasting stuff and test it :)

Modified Paths:
--------------
    trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm

Modified: trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm	2013-01-06 12:42:47 UTC (rev 53603)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm	2013-01-06 12:49:32 UTC (rev 53604)
@@ -1439,6 +1439,27 @@
 
 }
 
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070
+enum {
+    NSEventPhaseNone = 0,
+    NSEventPhaseBegan = 0x1 << 0,
+    NSEventPhaseStationary = 0x1 << 1,
+    NSEventPhaseChanged = 0x1 << 2,
+    NSEventPhaseEnded = 0x1 << 3,
+    NSEventPhaseCancelled = 0x1 << 4,
+};
+typedef NSUInteger NSEventPhase;
+
+ at interface NSEvent (AvailableOn1070AndLater)
+- (BOOL)hasPreciseScrollingDeltas;
+- (CGFloat)scrollingDeltaX;
+- (CGFloat)scrollingDeltaY;
+- (NSEventPhase)momentumPhase;
+- (BOOL)isDirectionInvertedFromDevice;
+- (NSEventPhase)phase;
+ at end
+#endif
+
 GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
 {
 	NSEvent *event = (NSEvent *)eventPtr;
@@ -1581,10 +1602,13 @@
 			
 		case NSScrollWheel:
 			{
-				int momentum = [event momentumPhase];
+				int *momentum = NULL;
+				
+				if ([event respondsToSelector:@selector(momentumPhase)])
+					momentum = (int *)[event momentumPhase];
 
 				/* standard scrollwheel case, if no swiping happened, and no momentum (kinetic scroll) works */
-				if (!m_hasMultiTouchTrackpad && momentum == 0) {
+				if (!m_hasMultiTouchTrackpad && momentum == NULL) {
 					GHOST_TInt32 delta;
 					
 					double deltaF = [event deltaY];




More information about the Bf-blender-cvs mailing list