diff options
author | Damien Plisson <damien.plisson@yahoo.fr> | 2010-04-11 15:19:30 +0400 |
---|---|---|
committer | Damien Plisson <damien.plisson@yahoo.fr> | 2010-04-11 15:19:30 +0400 |
commit | 5c24ce16b2b340fcbd62cd6b1452c9023c6d54b9 (patch) | |
tree | e163d6727c68afab7439fca6665d91454d113399 | |
parent | f3f8855dfe996e0744e3e523359cabbf4af29025 (diff) |
Cocoa fix [#21866] : force mouse move event to be sent upon cursor position set request
-rw-r--r-- | intern/ghost/GHOST_ISystem.h | 2 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemCarbon.cpp | 2 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemCarbon.h | 2 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemCocoa.h | 12 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemCocoa.mm | 20 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemWin32.cpp | 2 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemWin32.h | 2 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemX11.cpp | 2 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemX11.h | 2 |
9 files changed, 35 insertions, 11 deletions
diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h index fd8641f2055..8d80c74e140 100644 --- a/intern/ghost/GHOST_ISystem.h +++ b/intern/ghost/GHOST_ISystem.h @@ -331,7 +331,7 @@ public: * @param y The y-coordinate of the cursor. * @return Indication of success. */ - virtual GHOST_TSuccess setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y) const = 0; + virtual GHOST_TSuccess setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y) = 0; /*************************************************************************************** ** Access to mouse button and keyboard states. diff --git a/intern/ghost/intern/GHOST_SystemCarbon.cpp b/intern/ghost/intern/GHOST_SystemCarbon.cpp index 36ea1c7fe85..5522a0736c4 100644 --- a/intern/ghost/intern/GHOST_SystemCarbon.cpp +++ b/intern/ghost/intern/GHOST_SystemCarbon.cpp @@ -531,7 +531,7 @@ GHOST_TSuccess GHOST_SystemCarbon::getCursorPosition(GHOST_TInt32& x, GHOST_TInt } -GHOST_TSuccess GHOST_SystemCarbon::setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y) const +GHOST_TSuccess GHOST_SystemCarbon::setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y) { float xf=(float)x, yf=(float)y; diff --git a/intern/ghost/intern/GHOST_SystemCarbon.h b/intern/ghost/intern/GHOST_SystemCarbon.h index 7f0870674b4..ebd929749b6 100644 --- a/intern/ghost/intern/GHOST_SystemCarbon.h +++ b/intern/ghost/intern/GHOST_SystemCarbon.h @@ -156,7 +156,7 @@ public: * @param y The y-coordinate of the cursor. * @return Indication of success. */ - virtual GHOST_TSuccess setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y) const; + virtual GHOST_TSuccess setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y); /*************************************************************************************** ** Access to mouse button and keyboard states. diff --git a/intern/ghost/intern/GHOST_SystemCocoa.h b/intern/ghost/intern/GHOST_SystemCocoa.h index b25f8890cf1..b97c36f04a8 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.h +++ b/intern/ghost/intern/GHOST_SystemCocoa.h @@ -179,8 +179,8 @@ public: * @param y The y-coordinate of the cursor. * @return Indication of success. */ - virtual GHOST_TSuccess setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y) const; - + virtual GHOST_TSuccess setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y); + /*************************************************************************************** ** Access to mouse button and keyboard states. ***************************************************************************************/ @@ -272,6 +272,14 @@ protected: */ GHOST_TSuccess handleKeyEvent(void *eventPtr); + /** + * Performs the actual cursor position update (location in screen coordinates). + * @param x The x-coordinate of the cursor. + * @param y The y-coordinate of the cursor. + * @return Indication of success. + */ + GHOST_TSuccess setMouseCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y); + /** Start time at initialization. */ GHOST_TUns64 m_start_time; diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index b66b1e4033d..eb89258e1dd 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -807,7 +807,23 @@ GHOST_TSuccess GHOST_SystemCocoa::getCursorPosition(GHOST_TInt32& x, GHOST_TInt3 /** * @note : expect Cocoa screen coordinates */ -GHOST_TSuccess GHOST_SystemCocoa::setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y) const +GHOST_TSuccess GHOST_SystemCocoa::setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y) +{ + GHOST_TInt32 wx,wy; + GHOST_WindowCocoa* window = (GHOST_WindowCocoa*)m_windowManager->getActiveWindow(); + if (!window) return GHOST_kFailure; + + setMouseCursorPosition(x, y); + + //Force mouse move event (not pushed by Cocoa) + window->screenToClient(x, y, wx, wy); + pushEvent(new GHOST_EventCursor(getMilliSeconds(), GHOST_kEventCursorMove, window, wx,wy)); + m_outsideLoopEventProcessed = true; + + return GHOST_kSuccess; +} + +GHOST_TSuccess GHOST_SystemCocoa::setMouseCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y) { float xf=(float)x, yf=(float)y; GHOST_WindowCocoa* window = (GHOST_WindowCocoa*)m_windowManager->getActiveWindow(); @@ -1517,7 +1533,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr) //Set new cursor position window->clientToScreen(x_mouse, y_mouse, x_cur, y_cur); - setCursorPosition(x_cur, y_cur); /* wrap */ + setMouseCursorPosition(x_cur, y_cur); /* wrap */ //Post event window->getCursorGrabInitPos(x_cur, y_cur); diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index b1c5ee6e6f2..c4cdbcd0cd5 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -273,7 +273,7 @@ GHOST_TSuccess GHOST_SystemWin32::getCursorPosition(GHOST_TInt32& x, GHOST_TInt3 } -GHOST_TSuccess GHOST_SystemWin32::setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y) const +GHOST_TSuccess GHOST_SystemWin32::setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y) { return ::SetCursorPos(x, y) == TRUE ? GHOST_kSuccess : GHOST_kFailure; } diff --git a/intern/ghost/intern/GHOST_SystemWin32.h b/intern/ghost/intern/GHOST_SystemWin32.h index 75bb858fb49..e65393a4faa 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.h +++ b/intern/ghost/intern/GHOST_SystemWin32.h @@ -153,7 +153,7 @@ public: * @param y The y-coordinate of the cursor. * @return Indication of success. */ - virtual GHOST_TSuccess setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y) const; + virtual GHOST_TSuccess setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y); /*************************************************************************************** ** Access to mouse button and keyboard states. diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index 1b7589fc432..2479d198970 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -970,7 +970,7 @@ GHOST_SystemX11:: setCursorPosition( GHOST_TInt32 x, GHOST_TInt32 y -) const { +) { // This is a brute force move in screen coordinates // XWarpPointer does relative moves so first determine the diff --git a/intern/ghost/intern/GHOST_SystemX11.h b/intern/ghost/intern/GHOST_SystemX11.h index 1d9959cc931..ee6cbedb2ae 100644 --- a/intern/ghost/intern/GHOST_SystemX11.h +++ b/intern/ghost/intern/GHOST_SystemX11.h @@ -158,7 +158,7 @@ public: setCursorPosition( GHOST_TInt32 x, GHOST_TInt32 y - ) const; + ); /** * Returns the state of all modifier keys. |