[Bf-blender-cvs] [43ee3f4] master: Fix T44739: OS X RMB emulation giving wrong mouse button release event.

Brecht Van Lommel noreply at git.blender.org
Sun May 17 16:55:46 CEST 2015


Commit: 43ee3f4040a41c637b6eceda4c3aa1046f8a13a5
Author: Brecht Van Lommel
Date:   Sun May 17 15:43:42 2015 +0200
Branches: master
https://developer.blender.org/rB43ee3f4040a41c637b6eceda4c3aa1046f8a13a5

Fix T44739: OS X RMB emulation giving wrong mouse button release event.

===================================================================

M	source/blender/windowmanager/intern/wm_event_system.c

===================================================================

diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 42fc026..658fb31 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -2886,52 +2886,41 @@ static int convert_key(GHOST_TKey key)
 
 static void wm_eventemulation(wmEvent *event)
 {
-	/* Store last mmb event value to make emulation work when modifier keys are released first. */
-	static int mmb_emulated = 0; /* this should be in a data structure somwhere */
+	/* Store last mmb/rmb event value to make emulation work when modifier keys
+	 * are released first. This really should be in a data structure somwhere. */
+	static int emulating_event = EVENT_NONE;
 	
-	/* middlemouse emulation */
+	/* middlemouse and rightmouse emulation */
 	if (U.flag & USER_TWOBUTTONMOUSE) {
 		if (event->type == LEFTMOUSE) {
 			
 			if (event->val == KM_PRESS && event->alt) {
 				event->type = MIDDLEMOUSE;
 				event->alt = 0;
-				mmb_emulated = 1;
+				emulating_event = MIDDLEMOUSE;
 			}
-			else if (event->val == KM_RELEASE) {
-				/* only send middle-mouse release if emulated */
-				if (mmb_emulated) {
-					event->type = MIDDLEMOUSE;
-					event->alt = 0;
-				}
-				mmb_emulated = 0;
-			}
-		}
-		
-	}
-	
 #ifdef __APPLE__
-	
-	/* rightmouse emulation */
-	if (U.flag & USER_TWOBUTTONMOUSE) {
-		if (event->type == LEFTMOUSE) {
-			
-			if (event->val == KM_PRESS && event->oskey) {
+			else if (event->val == KM_PRESS && event->oskey) {
 				event->type = RIGHTMOUSE;
 				event->oskey = 0;
-				mmb_emulated = 1;
+				emulating_event = RIGHTMOUSE;
 			}
+#endif
 			else if (event->val == KM_RELEASE) {
-				if (mmb_emulated) {
-					event->oskey = RIGHTMOUSE;
+				/* only send middle-mouse release if emulated */
+				if (emulating_event == MIDDLEMOUSE) {
+					event->type = MIDDLEMOUSE;
 					event->alt = 0;
 				}
-				mmb_emulated = 0;
+				else if (emulating_event == RIGHTMOUSE) {
+					event->type = RIGHTMOUSE;
+					event->oskey = 0;
+				}
+				emulating_event = EVENT_NONE;
 			}
 		}
 		
 	}
-#endif
 	
 	/* numpad emulation */
 	if (U.flag & USER_NONUMPAD) {




More information about the Bf-blender-cvs mailing list