[Bf-blender-cvs] [48f2f8b9094] temp-win32-grab-test: Test fix for T102346

Campbell Barton noreply at git.blender.org
Fri Nov 18 09:35:51 CET 2022


Commit: 48f2f8b90943552f21322a0dbba33a01aa0dedf5
Author: Campbell Barton
Date:   Fri Nov 18 19:34:24 2022 +1100
Branches: temp-win32-grab-test
https://developer.blender.org/rB48f2f8b90943552f21322a0dbba33a01aa0dedf5

Test fix for T102346

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

M	intern/ghost/intern/GHOST_SystemWin32.cpp
M	intern/ghost/intern/GHOST_SystemX11.cpp
M	intern/ghost/intern/GHOST_WindowWin32.cpp

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

diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index 54c892d296e..1bc5db00ef1 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -1055,16 +1055,23 @@ GHOST_EventCursor *GHOST_SystemWin32::processCursorEvent(GHOST_WindowWin32 *wind
     int32_t x_new = x_screen;
     int32_t y_new = y_screen;
     int32_t x_accum, y_accum;
-    GHOST_Rect bounds;
 
-    /* Fallback to window bounds. */
-    if (window->getCursorGrabBounds(bounds) == GHOST_kFailure) {
-      window->getClientBounds(bounds);
+    if (window->getCursorGrabMode() == GHOST_kGrabHide) {
+      /* Warp on the spot. */
+      window->getCursorGrabInitPos(x_new, y_new);
     }
+    else {
+      GHOST_Rect bounds;
+
+      /* Fallback to window bounds. */
+      if (window->getCursorGrabBounds(bounds) == GHOST_kFailure) {
+        window->getClientBounds(bounds);
+      }
 
-    /* Could also clamp to screen bounds wrap with a window outside the view will
-     * fail at the moment. Use inset in case the window is at screen bounds. */
-    bounds.wrapPoint(x_new, y_new, 2, window->getCursorGrabAxis());
+      /* Could also clamp to screen bounds wrap with a window outside the view will
+       * fail at the moment. Use inset in case the window is at screen bounds. */
+      bounds.wrapPoint(x_new, y_new, 2, window->getCursorGrabAxis());
+    }
 
     window->getCursorGrabAccum(x_accum, y_accum);
     if (x_new != x_screen || y_new != y_screen) {
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index 5c89febe97c..66e7a79d2bf 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -934,16 +934,24 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
         int32_t x_new = xme.x_root;
         int32_t y_new = xme.y_root;
         int32_t x_accum, y_accum;
-        GHOST_Rect bounds;
+        bool always_warp = false;
 
-        /* fallback to window bounds */
-        if (window->getCursorGrabBounds(bounds) == GHOST_kFailure) {
-          window->getClientBounds(bounds);
+        if (window->getCursorGrabMode() == GHOST_kGrabHide) {
+          /* Warp on the spot. */
+          window->getCursorGrabInitPos(x_new, y_new);
+          always_warp = true;
         }
+        else {
+          GHOST_Rect bounds;
+          /* Fallback to window bounds. */
+          if (window->getCursorGrabBounds(bounds) == GHOST_kFailure) {
+            window->getClientBounds(bounds);
+          }
 
-        /* Could also clamp to screen bounds wrap with a window outside the view will
-         * fail at the moment. Use offset of 8 in case the window is at screen bounds. */
-        bounds.wrapPoint(x_new, y_new, 8, window->getCursorGrabAxis());
+          /* Could also clamp to screen bounds wrap with a window outside the view will
+           * fail at the moment. Use offset of 8 in case the window is at screen bounds. */
+          bounds.wrapPoint(x_new, y_new, 8, window->getCursorGrabAxis());
+        }
 
         window->getCursorGrabAccum(x_accum, y_accum);
 
@@ -954,11 +962,11 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
            * We also have to add a few extra milliseconds of 'padding', as sometimes we get two
            * close events that will generate extra wrap on the same axis within those few
            * milliseconds. */
-          if (x_new != xme.x_root && xme.time > m_last_warp_x) {
+          if (x_new != xme.x_root && (always_warp || xme.time > m_last_warp_x)) {
             x_accum += (xme.x_root - x_new);
             m_last_warp_x = lastEventTime(xme.time) + 25;
           }
-          if (y_new != xme.y_root && xme.time > m_last_warp_y) {
+          if (y_new != xme.y_root && (always_warp || xme.time > m_last_warp_y)) {
             y_accum += (xme.y_root - y_new);
             m_last_warp_y = lastEventTime(xme.time) + 25;
           }
diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp
index e2d143ee5e6..25846f08c30 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.cpp
+++ b/intern/ghost/intern/GHOST_WindowWin32.cpp
@@ -805,6 +805,7 @@ HCURSOR GHOST_WindowWin32::getStandardCursor(GHOST_TStandardCursor shape) const
 
 void GHOST_WindowWin32::loadCursor(bool visible, GHOST_TStandardCursor shape) const
 {
+  return;
   if (!visible) {
     while (::ShowCursor(FALSE) >= 0)
       ;
@@ -823,6 +824,7 @@ void GHOST_WindowWin32::loadCursor(bool visible, GHOST_TStandardCursor shape) co
 
 GHOST_TSuccess GHOST_WindowWin32::setWindowCursorVisibility(bool visible)
 {
+  return GHOST_kSuccess;
   if (::GetForegroundWindow() == m_hWnd) {
     loadCursor(visible, getCursorShape());
   }



More information about the Bf-blender-cvs mailing list