[Bf-blender-cvs] [a5c2d0018cd] master: Fix T91932: number sliders wrap around when dragged for long distance on X11

Sebastiano Barrera noreply at git.blender.org
Thu Jul 21 19:02:53 CEST 2022


Commit: a5c2d0018cd9a5844d618aaed21f64f11f35a97a
Author: Sebastiano Barrera
Date:   Thu Jul 21 18:51:36 2022 +0200
Branches: master
https://developer.blender.org/rBa5c2d0018cd9a5844d618aaed21f64f11f35a97a

Fix T91932: number sliders wrap around when dragged for long distance on X11

The value of number sliders (e.g. the "end frame" button) wrap around to
their pre-click value when dragging them for a very long distance (e.g.
by lifting the mouse off the desk and placing it back on to keep
dragging in the same direction).

The problem is X11-specific, and due to XTranslateCoordinates using a
signed int16 behind the curtains, while its signature and the rest of
Blender uses int32. The solution is to only use XTranslateCoordinates on
(0, 0) to get the delta between the screen and client reference systems,
and applying the delta in a second step.

Differential Revision: https://developer.blender.org/D15507

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

M	intern/ghost/intern/GHOST_WindowX11.cpp

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

diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp
index 01045c516c1..2276e90387b 100644
--- a/intern/ghost/intern/GHOST_WindowX11.cpp
+++ b/intern/ghost/intern/GHOST_WindowX11.cpp
@@ -658,15 +658,15 @@ GHOST_TSuccess GHOST_WindowX11::setClientSize(uint32_t width, uint32_t height)
 
 void GHOST_WindowX11::screenToClient(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const
 {
-  /* This is correct! */
-
   int ax, ay;
   Window temp;
 
+  /* Use (0, 0) instead of (inX, inY) to work around overflow of signed int16 in
+   * the implementation of this function. */
   XTranslateCoordinates(
-      m_display, RootWindow(m_display, m_visualInfo->screen), m_window, inX, inY, &ax, &ay, &temp);
-  outX = ax;
-  outY = ay;
+      m_display, RootWindow(m_display, m_visualInfo->screen), m_window, 0, 0, &ax, &ay, &temp);
+  outX = ax + inX;
+  outY = ay + inY;
 }
 
 void GHOST_WindowX11::clientToScreen(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const



More information about the Bf-blender-cvs mailing list