[Bf-blender-cvs] [230744d6fd9] master: Revert "Fix T102346: Mouse escapes window during walk navigation"

Campbell Barton noreply at git.blender.org
Thu Dec 15 02:17:55 CET 2022


Commit: 230744d6fd96dcf5afe66a8f9b9f6f8bbe1f41bb
Author: Campbell Barton
Date:   Wed Dec 14 21:02:53 2022 +1100
Branches: master
https://developer.blender.org/rB230744d6fd96dcf5afe66a8f9b9f6f8bbe1f41bb

Revert "Fix T102346: Mouse escapes window during walk navigation"

This reverts commits
9fd6dae7939a65b67045749a0eadeb6864ded183,
4cac8025f00798938813f52dcb117be83db97f22 (minor cleanup).

Re-introducing T102346, which will be fixed in isolation.

Unfortunately even when the cursor is hidden & grabbed,
the underlying cursor coordinates are still shown in some cases.

This caused bug where dragging a button in the sculpt-context popup
would draw the brush at unexpected locations because internally
the cursor was warping in the middle of the window, reported as T102792.

Resolving this issue with the paint cursor is possible but tend towards
over-complicated solutions.

Revert this change in favor of a more localized workaround for walk-mode
(as was done prior [0] to fix T99021).

[0]: 4c4e8cc926a672ac60692b3fb8c20249f9cae679

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

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

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

diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index 8cb007a756a..d005eec3036 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -1075,46 +1075,17 @@ 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;
 
-    /* Warp within bounds. */
-    {
-      GHOST_Rect bounds;
-      int32_t bounds_margin = 0;
-      GHOST_TAxisFlag bounds_axis = GHOST_kAxisNone;
-
-      if (window->getCursorGrabMode() == GHOST_kGrabHide) {
-        window->getClientBounds(bounds);
-
-        /* WARNING(@campbellbarton): The current warping logic fails to warp on every event,
-         * so the box needs to small enough not to let the cursor escape the window but large
-         * enough that the cursor isn't being warped every time.
-         * If this was not the case it would be less trouble to simply warp the cursor to the
-         * center of the screen on every motion, see: D16558 (alternative fix for T102346). */
-        const int32_t subregion_div = 4; /* One quarter of the region. */
-        const int32_t size[2] = {bounds.getWidth(), bounds.getHeight()};
-        const int32_t center[2] = {(bounds.m_l + bounds.m_r) / 2, (bounds.m_t + bounds.m_b) / 2};
-        /* Shrink the box to prevent the cursor escaping. */
-        bounds.m_l = center[0] - (size[0] / (subregion_div * 2));
-        bounds.m_r = center[0] + (size[0] / (subregion_div * 2));
-        bounds.m_t = center[1] - (size[1] / (subregion_div * 2));
-        bounds.m_b = center[1] + (size[1] / (subregion_div * 2));
-        bounds_margin = 0;
-        bounds_axis = GHOST_TAxisFlag(GHOST_kAxisX | GHOST_kAxisY);
-      }
-      else {
-        /* Fallback to window bounds. */
-        if (window->getCursorGrabBounds(bounds) == GHOST_kFailure) {
-          window->getClientBounds(bounds);
-        }
-        bounds_margin = 2;
-        bounds_axis = 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, bounds_margin, bounds_axis);
+    /* 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());
+
     window->getCursorGrabAccum(x_accum, y_accum);
     if (x_new != x_screen || y_new != y_screen) {
       /* WORKAROUND: Store the current time so that we ignore outdated mousemove events. */
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index 4a723435806..4baa3ff598f 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -950,48 +950,17 @@ 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;
 
-        /* Warp within bounds. */
-        {
-          GHOST_Rect bounds;
-          int32_t bounds_margin = 0;
-          GHOST_TAxisFlag bounds_axis = GHOST_kAxisNone;
-
-          if (window->getCursorGrabMode() == GHOST_kGrabHide) {
-            window->getClientBounds(bounds);
-
-            /* TODO(@campbellbarton): warp the cursor to `window->getCursorGrabInitPos`,
-             * on every motion event, see: D16557 (alternative fix for T102346). */
-            const int32_t subregion_div = 4; /* One quarter of the region. */
-            const int32_t size[2] = {bounds.getWidth(), bounds.getHeight()};
-            const int32_t center[2] = {
-                (bounds.m_l + bounds.m_r) / 2,
-                (bounds.m_t + bounds.m_b) / 2,
-            };
-            /* Shrink the box to prevent the cursor escaping. */
-            bounds.m_l = center[0] - (size[0] / (subregion_div * 2));
-            bounds.m_r = center[0] + (size[0] / (subregion_div * 2));
-            bounds.m_t = center[1] - (size[1] / (subregion_div * 2));
-            bounds.m_b = center[1] + (size[1] / (subregion_div * 2));
-            bounds_margin = 0;
-            bounds_axis = GHOST_TAxisFlag(GHOST_kAxisX | GHOST_kAxisY);
-          }
-          else {
-            /* 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_margin = 8;
-            bounds_axis = 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, bounds_margin, bounds_axis);
+        /* 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());
+
         window->getCursorGrabAccum(x_accum, y_accum);
 
         if (x_new != xme.x_root || y_new != xme.y_root) {



More information about the Bf-blender-cvs mailing list