From a5c2d0018cd9a5844d618aaed21f64f11f35a97a Mon Sep 17 00:00:00 2001 From: Sebastiano Barrera Date: Thu, 21 Jul 2022 18:51:36 +0200 Subject: 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 --- intern/ghost/intern/GHOST_WindowX11.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'intern') 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 -- cgit v1.2.3