[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26954] trunk/blender/intern/ghost/intern/ GHOST_SystemCocoa.mm: Cocoa: bugfix [#21158] fix modifiers keys status upon gaining focus

Damien Plisson damien.plisson at yahoo.fr
Tue Feb 16 14:09:04 CET 2010


Revision: 26954
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=26954
Author:   damien78
Date:     2010-02-16 14:09:03 +0100 (Tue, 16 Feb 2010)

Log Message:
-----------
Cocoa: bugfix [#21158] fix modifiers keys status upon gaining focus

10.6 new function to get modifiers flags status asynchronously returns erroneous value when application gets focus after a virtual desktop switch (Spaces).
Use legacy method to retrieve the modifiers flags status sent with the last  event. Works as at least the "focus gained" event is sent before this query. Bonus: should work also on pre-10.6!

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	2010-02-16 10:36:17 UTC (rev 26953)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm	2010-02-16 13:09:03 UTC (rev 26954)
@@ -397,20 +397,9 @@
 #endif
 @end 
 
- at interface NSEvent(SnowLeopardEvents)
-/* modifier keys currently down.  This returns the state of devices combined
- with synthesized events at the moment, independent of which events
- have been delivered via the event stream. */
-#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
-+ (unsigned int)modifierFlags; //NSUInteger is defined only from 10.5
-#else
-+ (NSUInteger)modifierFlags;
 #endif
- at end
 
-#endif
 
-
 #pragma mark Utility functions
 
 #define FIRSTFILEBUFLG 512
@@ -945,22 +934,8 @@
 	}
 	else m_needDelayedApplicationBecomeActiveEventProcessing = false;
 
-#ifdef MAC_OS_X_VERSION_10_6
-	modifiers = [NSEvent modifierFlags];
-#else
-	//If build against an older SDK, check if running on 10.6 to use the correct function
-	if ([NSEvent respondsToSelector:@selector(modifierFlags)]) {
-		modifiers = [NSEvent modifierFlags];
-	}
-	else {
-		//TODO: need to find a better workaround for the missing cocoa "getModifierFlag" function in 10.4/10.5
-		modifiers = 0;
-	}
-#endif
+	modifiers = [[[NSApplication sharedApplication] currentEvent] modifierFlags];
 	
-	/* Discard erroneous 10.6 modifiers values reported when switching back from spaces */
-	if ((modifiers & NSDeviceIndependentModifierFlagsMask) == 0xb00000) modifiers = 0;
-	
 	if ((modifiers & NSShiftKeyMask) != (m_modifierMask & NSShiftKeyMask)) {
 		pushEvent( new GHOST_EventKey(getMilliSeconds(), (modifiers & NSShiftKeyMask)?GHOST_kEventKeyDown:GHOST_kEventKeyUp, window, GHOST_kKeyLeftShift) );
 	}





More information about the Bf-blender-cvs mailing list