Fix T48901: Blender ignores xinput cursor matrix

This commit is contained in:
Campbell Barton 2016-08-01 13:40:59 +10:00
parent a3ce64be5a
commit 7065022f7a
Notes: blender-bot 2023-02-14 08:45:12 +01:00
Referenced by commit 8825a8e951, Squashed commit of the following:
Referenced by issue #50383, Mouse jumps monitors on middle button release
Referenced by issue #48992, Unicode strings in ID properties cause UI glitch
Referenced by issue #48901, Blender ignores xinput mouse sensitivity (as a result, mouse cursor randomly jumps when I attempt to navigate, move objects, etc.)
2 changed files with 41 additions and 2 deletions

View File

@ -61,6 +61,11 @@
#include <X11/XF86keysym.h>
#endif
/* for XIWarpPointer */
#ifdef WITH_X11_XINPUT
# include <X11/extensions/XInput2.h>
#endif
/* For timing */
#include <sys/time.h>
#include <unistd.h>
@ -1469,7 +1474,22 @@ setCursorPosition(
int relx = x - cx;
int rely = y - cy;
XWarpPointer(m_display, None, None, 0, 0, 0, 0, relx, rely);
#ifdef WITH_X11_XINPUT
if ((m_xinput_version.present) &&
(m_xinput_version.major_version >= 2))
{
/* Needed to account for XInput "Coordinate Transformation Matrix", see T48901 */
int device_id;
if (XIGetClientPointer(m_display, None, &device_id) != False) {
XIWarpPointer(m_display, device_id, None, None, 0, 0, 0, 0, relx, rely);
}
}
else
#endif
{
XWarpPointer(m_display, None, None, 0, 0, 0, 0, relx, rely);
}
XSync(m_display, 0); /* Sync to process all requests */
return GHOST_kSuccess;

View File

@ -51,6 +51,11 @@
# include "GHOST_ContextGLX.h"
#endif
/* for XIWarpPointer */
#ifdef WITH_X11_XINPUT
# include <X11/extensions/XInput2.h>
#endif
#if defined(__sun__) || defined(__sun) || defined(__sparc) || defined(__sparc__) || defined(_AIX)
# include <strings.h>
#endif
@ -1520,7 +1525,21 @@ setWindowCursorGrab(
/* use to generate a mouse move event, otherwise the last event
* blender gets can be outside the screen causing menus not to show
* properly unless the user moves the mouse */
XWarpPointer(m_display, None, None, 0, 0, 0, 0, 0, 0);
#ifdef WITH_X11_XINPUT
if ((m_system->m_xinput_version.present) &&
(m_system->m_xinput_version.major_version >= 2))
{
int device_id;
if (XIGetClientPointer(m_display, None, &device_id) != False) {
XIWarpPointer(m_display, device_id, None, None, 0, 0, 0, 0, 0, 0);
}
}
else
#endif
{
XWarpPointer(m_display, None, None, 0, 0, 0, 0, 0, 0);
}
}
/* Almost works without but important otherwise the mouse GHOST location can be incorrect on exit */