[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46356] trunk/blender/intern/ghost/intern: code cleanup: add getCursorGrabModeIsWarp(), makes the intent more clear where we check for mouse warping.

Campbell Barton ideasman42 at gmail.com
Sun May 6 17:59:58 CEST 2012


Revision: 46356
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46356
Author:   campbellbarton
Date:     2012-05-06 15:59:57 +0000 (Sun, 06 May 2012)
Log Message:
-----------
code cleanup: add getCursorGrabModeIsWarp(), makes the intent more clear where we check for mouse warping.

Modified Paths:
--------------
    trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm
    trunk/blender/intern/ghost/intern/GHOST_SystemWin32.cpp
    trunk/blender/intern/ghost/intern/GHOST_SystemX11.cpp
    trunk/blender/intern/ghost/intern/GHOST_Window.h

Modified: trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm	2012-05-06 15:45:48 UTC (rev 46355)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm	2012-05-06 15:59:57 UTC (rev 46356)
@@ -1280,7 +1280,7 @@
 	GHOST_Window* window = (GHOST_Window*)m_windowManager->getActiveWindow();
 	
 	//Discard quit event if we are in cursor grab sequence
-	if (window && (window->getCursorGrabMode() != GHOST_kGrabDisable) && (window->getCursorGrabMode() != GHOST_kGrabNormal))
+	if (window && window->getCursorGrabModeIsWarp())
 		return GHOST_kExitCancel;
 	
 	//Check open windows if some changes are not saved
@@ -1329,7 +1329,7 @@
 	}	
 	
 	//Discard event if we are in cursor grab sequence, it'll lead to "stuck cursor" situation if the alert panel is raised
-	if (window && (window->getCursorGrabMode() != GHOST_kGrabDisable) && (window->getCursorGrabMode() != GHOST_kGrabNormal))
+	if (window && window->getCursorGrabModeIsWarp())
 		return GHOST_kExitCancel;
 
 	//Check open windows if some changes are not saved
@@ -1493,10 +1493,7 @@
 				/* TODO: CHECK IF THIS IS A TABLET EVENT */
 				bool is_tablet = false;
 
-				if (is_tablet &&
-				    (grab_mode != GHOST_kGrabDisable) &&
-				    (grab_mode != GHOST_kGrabNormal))
-				{
+				if (is_tablet && window->getCursorGrabModeIsWarp()) {
 					grab_mode = GHOST_kGrabDisable;
 				}
 

Modified: trunk/blender/intern/ghost/intern/GHOST_SystemWin32.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemWin32.cpp	2012-05-06 15:45:48 UTC (rev 46355)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemWin32.cpp	2012-05-06 15:59:57 UTC (rev 46356)
@@ -652,10 +652,7 @@
 	/* TODO: CHECK IF THIS IS A TABLET EVENT */
 	bool is_tablet = false;
 
-	if (is_tablet == false &&
-	    window->getCursorGrabMode() != GHOST_kGrabDisable &&
-	    window->getCursorGrabMode() != GHOST_kGrabNormal)
-	{
+	if (is_tablet == false && window->getCursorGrabModeIsWarp()) {
 		GHOST_TInt32 x_new= x_screen;
 		GHOST_TInt32 y_new= y_screen;
 		GHOST_TInt32 x_accum, y_accum;

Modified: trunk/blender/intern/ghost/intern/GHOST_SystemX11.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemX11.cpp	2012-05-06 15:45:48 UTC (rev 46355)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemX11.cpp	2012-05-06 15:59:57 UTC (rev 46356)
@@ -478,10 +478,7 @@
 			bool is_tablet = false;
 #endif
 
-			if(is_tablet == false &&
-			   window->getCursorGrabMode() != GHOST_kGrabDisable &&
-			   window->getCursorGrabMode() != GHOST_kGrabNormal)
-			{
+			if (is_tablet == false && window->getCursorGrabModeIsWarp()) {
 				GHOST_TInt32 x_new= xme.x_root;
 				GHOST_TInt32 y_new= xme.y_root;
 				GHOST_TInt32 x_accum, y_accum;

Modified: trunk/blender/intern/ghost/intern/GHOST_Window.h
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_Window.h	2012-05-06 15:45:48 UTC (rev 46355)
+++ trunk/blender/intern/ghost/intern/GHOST_Window.h	2012-05-06 15:59:57 UTC (rev 46356)
@@ -161,6 +161,7 @@
 	 */
 	inline virtual bool getCursorVisibility() const;
 	inline virtual GHOST_TGrabCursorMode getCursorGrabMode() const;
+	inline virtual bool getCursorGrabModeIsWarp() const;
 	inline virtual void getCursorGrabInitPos(GHOST_TInt32 &x, GHOST_TInt32 &y) const;
 	inline virtual void getCursorGrabAccum(GHOST_TInt32 &x, GHOST_TInt32 &y) const;
 	inline virtual void setCursorGrabAccum(GHOST_TInt32 x, GHOST_TInt32 y);
@@ -362,6 +363,12 @@
 	return m_cursorGrab;
 }
 
+inline bool GHOST_Window::getCursorGrabModeIsWarp() const
+{
+	return  (m_cursorGrab == GHOST_kGrabWrap) ||
+	        (m_cursorGrab == GHOST_kGrabHide);
+}
+
 inline void GHOST_Window::getCursorGrabInitPos(GHOST_TInt32 &x, GHOST_TInt32 &y) const
 {
 	x = m_cursorGrabInitPos[0];




More information about the Bf-blender-cvs mailing list