Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-05-06 19:59:57 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-05-06 19:59:57 +0400
commitd5b96163f7f5ad341d5e252f88c4126b562317b3 (patch)
tree46f2edb494dd766e51a4f19c2aba4327e970e015 /intern/ghost
parent4504c66124203134fb70e9008082ef966db4a544 (diff)
code cleanup: add getCursorGrabModeIsWarp(), makes the intent more clear where we check for mouse warping.
Diffstat (limited to 'intern/ghost')
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.mm9
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.cpp5
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.cpp5
-rw-r--r--intern/ghost/intern/GHOST_Window.h7
4 files changed, 12 insertions, 14 deletions
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm
index 898171b344e..77d9e39a752 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -1280,7 +1280,7 @@ GHOST_TUns8 GHOST_SystemCocoa::handleQuitRequest()
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 @@ bool GHOST_SystemCocoa::handleOpenDocumentRequest(void *filepathStr)
}
//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 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
/* 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;
}
diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index b00ff690cfa..9f2728a581f 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -652,10 +652,7 @@ GHOST_EventCursor* GHOST_SystemWin32::processCursorEvent(GHOST_TEventType type,
/* 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;
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index 6a2e6f59717..cabec06301a 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -478,10 +478,7 @@ GHOST_SystemX11::processEvent(XEvent *xe)
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;
diff --git a/intern/ghost/intern/GHOST_Window.h b/intern/ghost/intern/GHOST_Window.h
index 323e0fa3418..23f1b044b60 100644
--- a/intern/ghost/intern/GHOST_Window.h
+++ b/intern/ghost/intern/GHOST_Window.h
@@ -161,6 +161,7 @@ public:
*/
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 @@ inline GHOST_TGrabCursorMode GHOST_Window::getCursorGrabMode() const
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];