147 lines
5.8 KiB
Diff
147 lines
5.8 KiB
Diff
Description: Fix XInput event valuator access.
|
|
Fix was proposed upstream at
|
|
https://qt.gitorious.org/qt/qt/merge_requests/1397 but Qt since moved to
|
|
gerrit. Needs re-forwarding.
|
|
Author: Jussi Pakkanen <jussi.pakkanen@ubuntu.com>
|
|
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/qt4-x11/+bug/799202
|
|
Forwarded: no
|
|
|
|
---
|
|
src/gui/kernel/qapplication_x11.cpp | 96 ++++++++++++++++++++++++++++++------
|
|
1 file changed, 82 insertions(+), 14 deletions(-)
|
|
|
|
--- a/src/gui/kernel/qapplication_x11.cpp
|
|
+++ b/src/gui/kernel/qapplication_x11.cpp
|
|
@@ -4809,6 +4809,20 @@
|
|
return false;
|
|
}
|
|
|
|
+/* XInput only reports those valuators whose values have changed.
|
|
+ * We have to preserve old values. This is a quick hack to test
|
|
+ * whether it works or not. It will most likely fail in several
|
|
+ * ways if, for example, there is more than one tablet event
|
|
+ * source or anything like that.
|
|
+ */
|
|
+
|
|
+static int previousXLoc = 0;
|
|
+static int previousYLoc = 0;
|
|
+static int previousXTilt = 0;
|
|
+static int previousYTilt = 0;
|
|
+static qreal previousPressure = 0;
|
|
+static qreal previousRotation = 0;
|
|
+
|
|
bool QETWidget::translateXinputEvent(const XEvent *ev, QTabletDeviceData *tablet)
|
|
{
|
|
#if defined (Q_OS_IRIX)
|
|
@@ -4827,12 +4841,14 @@
|
|
QPoint global,
|
|
curr;
|
|
QPointF hiRes;
|
|
- qreal pressure = 0;
|
|
- int xTilt = 0,
|
|
- yTilt = 0,
|
|
+ qreal pressure = previousPressure;
|
|
+ int xLoc = previousXLoc,
|
|
+ yLoc = previousYLoc,
|
|
+ xTilt = previousXTilt,
|
|
+ yTilt = previousYTilt,
|
|
z = 0;
|
|
qreal tangentialPressure = 0;
|
|
- qreal rotation = 0;
|
|
+ qreal rotation = previousRotation;
|
|
int deviceType = QTabletEvent::NoDevice;
|
|
int pointerType = QTabletEvent::UnknownPointer;
|
|
const XDeviceMotionEvent *motion = 0;
|
|
@@ -4976,22 +4992,64 @@
|
|
fetchWacomToolId(deviceType, uid);
|
|
|
|
QRect screenArea = qApp->desktop()->rect();
|
|
+ const unsigned char xIndex = 0;
|
|
+ const unsigned char yIndex = 1;
|
|
+ const unsigned char pressureIndex = 2;
|
|
+ const unsigned char xTiltIndex = 3;
|
|
+ const unsigned char yTiltIndex = 4;
|
|
+ const unsigned char rotationIndex = 5;
|
|
if (motion) {
|
|
- xTilt = (short) motion->axis_data[3];
|
|
- yTilt = (short) motion->axis_data[4];
|
|
- rotation = ((short) motion->axis_data[5]) / 64.0;
|
|
- pressure = (short) motion->axis_data[2];
|
|
+ const unsigned char firstAxis = motion->first_axis;
|
|
+ const unsigned char axesCount = motion->axes_count;
|
|
+ const unsigned char maxIndex = firstAxis + axesCount;
|
|
+
|
|
+ if (xIndex >= firstAxis && xIndex < maxIndex)
|
|
+ xLoc = motion->axis_data[xIndex - firstAxis];
|
|
+
|
|
+ if (yIndex >= firstAxis && yIndex < maxIndex)
|
|
+ yLoc = motion->axis_data[yIndex - firstAxis];
|
|
+
|
|
+ if (xTiltIndex >= firstAxis && xTiltIndex < maxIndex)
|
|
+ xTilt = (short) motion->axis_data[xTiltIndex - firstAxis];
|
|
+
|
|
+ if (yTiltIndex >= firstAxis && yTiltIndex < maxIndex)
|
|
+ yTilt = (short) motion->axis_data[yTiltIndex - firstAxis];
|
|
+
|
|
+ if (rotationIndex >= firstAxis && rotationIndex < maxIndex)
|
|
+ rotation = ((short) motion->axis_data[rotationIndex - firstAxis]) / 64.0;
|
|
+
|
|
+ if (pressureIndex >= firstAxis && pressureIndex < maxIndex)
|
|
+ pressure = (short) motion->axis_data[pressureIndex - firstAxis];
|
|
+
|
|
modifiers = X11->translateModifiers(motion->state);
|
|
- hiRes = tablet->scaleCoord(motion->axis_data[0], motion->axis_data[1],
|
|
+ hiRes = tablet->scaleCoord(xLoc, yLoc,
|
|
screenArea.x(), screenArea.width(),
|
|
screenArea.y(), screenArea.height());
|
|
} else if (button) {
|
|
- xTilt = (short) button->axis_data[3];
|
|
- yTilt = (short) button->axis_data[4];
|
|
- rotation = ((short) button->axis_data[5]) / 64.0;
|
|
- pressure = (short) button->axis_data[2];
|
|
+ const unsigned char firstAxis = button->first_axis;
|
|
+ const unsigned char axesCount = button->axes_count;
|
|
+ const unsigned char maxIndex = firstAxis + axesCount;
|
|
+
|
|
+ if (xIndex >= firstAxis && xIndex < maxIndex)
|
|
+ xLoc = button->axis_data[xIndex - firstAxis];
|
|
+
|
|
+ if (yIndex >= firstAxis && yIndex < maxIndex)
|
|
+ yLoc = button->axis_data[yIndex - firstAxis];
|
|
+
|
|
+ if (xTiltIndex >= firstAxis && xTiltIndex < maxIndex)
|
|
+ xTilt = (short) button->axis_data[xTiltIndex - firstAxis];
|
|
+
|
|
+ if (yTiltIndex >= firstAxis && yTiltIndex < maxIndex)
|
|
+ yTilt = (short) button->axis_data[yTiltIndex - firstAxis];
|
|
+
|
|
+ if (rotationIndex >= firstAxis && rotationIndex < maxIndex)
|
|
+ rotation = ((short) button->axis_data[rotationIndex - firstAxis]) / 64.0;
|
|
+
|
|
+ if (pressureIndex >= firstAxis && pressureIndex < maxIndex)
|
|
+ pressure = (short) button->axis_data[pressureIndex - firstAxis];
|
|
+
|
|
modifiers = X11->translateModifiers(button->state);
|
|
- hiRes = tablet->scaleCoord(button->axis_data[0], button->axis_data[1],
|
|
+ hiRes = tablet->scaleCoord(xLoc, yLoc,
|
|
screenArea.x(), screenArea.width(),
|
|
screenArea.y(), screenArea.height());
|
|
} else if (proximity) {
|
|
@@ -5025,6 +5083,16 @@
|
|
deviceType, pointerType,
|
|
qreal(pressure / qreal(tablet->maxPressure - tablet->minPressure)),
|
|
xTilt, yTilt, tangentialPressure, rotation, z, modifiers, uid);
|
|
+ /* Preserve current values because the X server will *not*
|
|
+ * re-send them if they do not change.
|
|
+ */
|
|
+ previousXLoc = xLoc;
|
|
+ previousYLoc = yLoc;
|
|
+ previousXTilt = xTilt;
|
|
+ previousYTilt = yTilt;
|
|
+ previousPressure = pressure;
|
|
+ previousRotation = rotation;
|
|
+
|
|
if (proximity) {
|
|
QApplication::sendSpontaneousEvent(qApp, &e);
|
|
} else {
|