[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26001] trunk/blender/intern/ghost/intern: Cocoa : fix for modifiers keys handling upon application switching

Damien Plisson damien.plisson at yahoo.fr
Thu Jan 14 17:01:08 CET 2010


Revision: 26001
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=26001
Author:   damien78
Date:     2010-01-14 17:01:05 +0100 (Thu, 14 Jan 2010)

Log Message:
-----------
Cocoa : fix for modifiers keys handling upon application switching

- fix race condition between applicationBecomeActive, and WindowBecomeKey events that discarded the modifiers keys status change event message
- workaround for a 10.6 bug that made the Cmd (oskey) modifier erroneously on.

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

Modified: trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.h
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.h	2010-01-14 14:33:05 UTC (rev 26000)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.h	2010-01-14 16:01:05 UTC (rev 26001)
@@ -264,6 +264,9 @@
 	/** Event has been processed directly by Cocoa and has sent a ghost event to be dispatched */
 	bool m_outsideLoopEventProcessed;
 	
+	/** Raised window is not yet known by the window manager, so delay application become active event handling */
+	bool m_needDelayedApplicationBecomeActiveEventProcessing;
+	
 	/** Mouse buttons state */
 	GHOST_TUns32 m_pressedMouseButtons;
 	

Modified: trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm	2010-01-14 14:33:05 UTC (rev 26000)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm	2010-01-14 16:01:05 UTC (rev 26001)
@@ -520,6 +520,7 @@
 	m_cursorDelta_x=0;
 	m_cursorDelta_y=0;
 	m_outsideLoopEventProcessed = false;
+	m_needDelayedApplicationBecomeActiveEventProcessing = false;
 	m_displayManager = new GHOST_DisplayManagerCocoa ();
 	GHOST_ASSERT(m_displayManager, "GHOST_SystemCocoa::GHOST_SystemCocoa(): m_displayManager==0\n");
 	m_displayManager->initialize();
@@ -919,6 +920,8 @@
 		} while (event!= nil);		
 	//} while (waitForEvent && !anyProcessed); Needed only for timer implementation
 	
+	if (m_needDelayedApplicationBecomeActiveEventProcessing) handleApplicationBecomeActiveEvent();
+	
 	if (m_outsideLoopEventProcessed) {
 		m_outsideLoopEventProcessed = false;
 		return true;
@@ -934,6 +937,12 @@
 	//(that is when update events are sent to another application)
 	unsigned int modifiers;
 	GHOST_IWindow* window = m_windowManager->getActiveWindow();
+	
+	if (!window) {
+		m_needDelayedApplicationBecomeActiveEventProcessing = true;
+		return GHOST_kFailure;
+	}
+	else m_needDelayedApplicationBecomeActiveEventProcessing = false;
 
 #ifdef MAC_OS_X_VERSION_10_6
 	modifiers = [NSEvent modifierFlags];
@@ -948,6 +957,9 @@
 	}
 #endif
 	
+	/* 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) );
 	}
@@ -963,6 +975,7 @@
 	
 	m_modifierMask = modifiers;
 	
+	m_outsideLoopEventProcessed = true;
 	return GHOST_kSuccess;
 }
 
@@ -1430,7 +1443,7 @@
 	 * the window go away and we still get an HKey up. 
 	 */
 	if (!window) {
-		printf("\nW failure");
+		//printf("\nW failure");
 		return GHOST_kFailure;
 	}
 	





More information about the Bf-blender-cvs mailing list