[Bf-blender-cvs] [08fa18fb6e3] blender-v3.4-release: Fix cursor warping display under Wayland

Campbell Barton noreply at git.blender.org
Fri Dec 16 16:03:31 CET 2022


Commit: 08fa18fb6e3f86854c08fda1c3574ca6166ff42a
Author: Campbell Barton
Date:   Thu Dec 15 15:19:57 2022 +1100
Branches: blender-v3.4-release
https://developer.blender.org/rB08fa18fb6e3f86854c08fda1c3574ca6166ff42a

Fix cursor warping display under Wayland

Under Wayland the transform cursor wasn't displaying the warped cursor.

This worked on other platforms because cursor motion is warped where as
Wayland simulates cursor warping, so it's necessary to apply warping
when requesting the cursor location too.

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

M	intern/ghost/intern/GHOST_SystemWayland.cpp

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

diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp
index 285fbbd3b6c..b50c2b386c2 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -5826,8 +5826,36 @@ static GHOST_TSuccess getCursorPositionClientRelative_impl(
     int32_t &y)
 {
   const wl_fixed_t scale = win->scale();
-  x = wl_fixed_to_int(scale * seat_state_pointer->xy[0]);
-  y = wl_fixed_to_int(scale * seat_state_pointer->xy[1]);
+
+  if (win->getCursorGrabModeIsWarp()) {
+    /* As the cursor is restored at the warped location,
+     * apply warping when requesting the cursor location. */
+    GHOST_Rect wrap_bounds{};
+    if (win->getCursorGrabModeIsWarp()) {
+      if (win->getCursorGrabBounds(wrap_bounds) == GHOST_kFailure) {
+        win->getClientBounds(wrap_bounds);
+      }
+    }
+    int xy_wrap[2] = {
+        seat_state_pointer->xy[0],
+        seat_state_pointer->xy[1],
+    };
+
+    GHOST_Rect wrap_bounds_scale;
+    wrap_bounds_scale.m_l = wl_fixed_from_int(wrap_bounds.m_l) / scale;
+    wrap_bounds_scale.m_t = wl_fixed_from_int(wrap_bounds.m_t) / scale;
+    wrap_bounds_scale.m_r = wl_fixed_from_int(wrap_bounds.m_r) / scale;
+    wrap_bounds_scale.m_b = wl_fixed_from_int(wrap_bounds.m_b) / scale;
+    wrap_bounds_scale.wrapPoint(UNPACK2(xy_wrap), 0, win->getCursorGrabAxis());
+
+    x = wl_fixed_to_int(scale * xy_wrap[0]);
+    y = wl_fixed_to_int(scale * xy_wrap[1]);
+  }
+  else {
+    x = wl_fixed_to_int(scale * seat_state_pointer->xy[0]);
+    y = wl_fixed_to_int(scale * seat_state_pointer->xy[1]);
+  }
+
   return GHOST_kSuccess;
 }



More information about the Bf-blender-cvs mailing list