Cocoa fix [#21866] : force mouse move event to be sent upon cursor position set request
authorDamien Plisson <damien.plisson@yahoo.fr>
Sun, 11 Apr 2010 11:19:30 +0000 (11:19 +0000)
committerDamien Plisson <damien.plisson@yahoo.fr>
Sun, 11 Apr 2010 11:19:30 +0000 (11:19 +0000)
intern/ghost/GHOST_ISystem.h
intern/ghost/intern/GHOST_SystemCarbon.cpp
intern/ghost/intern/GHOST_SystemCarbon.h
intern/ghost/intern/GHOST_SystemCocoa.h
intern/ghost/intern/GHOST_SystemCocoa.mm
intern/ghost/intern/GHOST_SystemWin32.cpp
intern/ghost/intern/GHOST_SystemWin32.h
intern/ghost/intern/GHOST_SystemX11.cpp
intern/ghost/intern/GHOST_SystemX11.h

index fd8641f2055eecb6f4804b6e0ba79baaed92b8cf..8d80c74e1409c3bbd1e508c2eb9bd6c0ed19b656 100644 (file)
@@ -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.
index 36ea1c7fe853ca2c3170d5524fcb279e577366f4..5522a0736c4f6b6baa161a11084d3fc18924d75a 100644 (file)
@@ -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;
 
index 7f0870674b4177965e362906b9962730c7222833..ebd929749b60e7e83dfb4465deb66eb033088f23 100644 (file)
@@ -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.
index b25f8890cf13edeaaa01f5054fa93cc31e6a752f..b97c36f04a8e0d2cceb6e00ae5128c264d3cac8e 100644 (file)
@@ -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;
        
index b66b1e4033d96313744bd88d3a14318a96e345d8..eb89258e1dd208d62230a59d05646914c9d748fb 100644 (file)
@@ -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);
index b1c5ee6e6f2616e8af4b392c3017ae18d4ab4dca..c4cdbcd0cd54b1e190c30a5e902c3141b0d72ca6 100644 (file)
@@ -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;
 }
index 75bb858fb495d8e8f30ce1d38a9719f404fa3258..e65393a4faa704cec0fb5a2d72b280d7520855a5 100644 (file)
@@ -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.
index 1b7589fc43271987e0541c3e5b2d60f9060a48c5..2479d198970782d30f127d69ef6e39ddcc2ad990 100644 (file)
@@ -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
index 1d9959cc9319697347aed6b83976bb631a9901c4..ee6cbedb2aee88f26d0b2e91aca0ee94b81c06c6 100644 (file)
@@ -158,7 +158,7 @@ public:
        setCursorPosition(
                GHOST_TInt32 x,
                GHOST_TInt32 y
-       ) const;
+       );
 
        /**
         * Returns the state of all modifier keys.