summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2014-04-29 12:32:34 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-05-05 11:30:34 +0200
commitb80f732783e43dc21ddbce4b42d9bb61915a3fb6 (patch)
treefad7ae37cb23b569dece3ce3b89cd453873149d2
parent3f885939c059605a9324a94e488793455c9cd848 (diff)
Use XI2 event detail to determine changed mouse buttonv5.3.0-rc1
The button state part of the XI2 events appears to be badly constructed on some devices and platforms. Even where supported the 'detail' field of the XI2 events is what we should be reading since it indicates the button the event refers to and not just the state of all buttons. Task-number: QTBUG-38169 Change-Id: Iedb7971194b3c27448b72c285a54100c511c17e4 Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp13
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.h1
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection_xi2.cpp12
3 files changed, 6 insertions, 20 deletions
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index e3b81c2b40..f5f6c712c5 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -1791,19 +1791,6 @@ bool QXcbConnection::xi2GetValuatorValueIfSet(void *event, int valuatorNum, doub
return true;
}
-bool QXcbConnection::xi2GetButtonState(void *event, int buttonNum)
-{
- xXIDeviceEvent *xideviceevent = static_cast<xXIDeviceEvent *>(event);
- unsigned char *buttonsMaskAddr = (unsigned char*)&xideviceevent[1];
-
- for (int i = 0; i < (xideviceevent->buttons_len * 4); i++) {
- if (buttonNum < 8)
- return (buttonsMaskAddr[i] & (1 << buttonNum));
- buttonNum -= 8;
- }
- return false;
-}
-
// Starting from the xcb version 1.9.3 struct xcb_ge_event_t has changed:
// - "pad0" became "extension"
// - "pad1" and "pad" became "pad0"
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h
index 1933b89a19..6e511356c4 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.h
+++ b/src/plugins/platforms/xcb/qxcbconnection.h
@@ -532,7 +532,6 @@ private:
#if defined(XCB_USE_XINPUT2) || defined(XCB_USE_XINPUT2_MAEMO)
static bool xi2GetValuatorValueIfSet(void *event, int valuatorNum, double *value);
static bool xi2PrepareXIGenericDeviceEvent(xcb_ge_event_t *event, int opCode);
- static bool xi2GetButtonState(void *event, int buttonNum);
#endif
xcb_connection_t *m_connection;
diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
index 831ccba6f6..efa1691780 100644
--- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
@@ -575,7 +575,7 @@ void QXcbConnection::xi2HandleScrollEvent(void *event, ScrollingDevice &scrollin
#ifdef XCB_USE_XINPUT21
xXIGenericDeviceEvent *xiEvent = reinterpret_cast<xXIGenericDeviceEvent *>(event);
- if (xiEvent->evtype == XI_Motion) {
+ if (xiEvent->evtype == XI_Motion && scrollingDevice.orientations) {
xXIDeviceEvent* xiDeviceEvent = reinterpret_cast<xXIDeviceEvent *>(event);
if (QXcbWindow *platformWindow = platformWindowFromId(xiDeviceEvent->event)) {
QPoint rawDelta;
@@ -612,20 +612,20 @@ void QXcbConnection::xi2HandleScrollEvent(void *event, ScrollingDevice &scrollin
QWindowSystemInterface::handleWheelEvent(platformWindow->window(), xiEvent->time, local, global, rawDelta, angleDelta, modifiers);
}
}
- } else if (xiEvent->evtype == XI_ButtonRelease) {
+ } else if (xiEvent->evtype == XI_ButtonRelease && scrollingDevice.legacyOrientations) {
xXIDeviceEvent* xiDeviceEvent = reinterpret_cast<xXIDeviceEvent *>(event);
if (QXcbWindow *platformWindow = platformWindowFromId(xiDeviceEvent->event)) {
QPoint angleDelta;
if (scrollingDevice.legacyOrientations & Qt::Vertical) {
- if (xi2GetButtonState(xiDeviceEvent, 4))
+ if (xiDeviceEvent->detail == 4)
angleDelta.setY(120);
- else if (xi2GetButtonState(xiDeviceEvent, 5))
+ else if (xiDeviceEvent->detail == 5)
angleDelta.setY(-120);
}
if (scrollingDevice.legacyOrientations & Qt::Horizontal) {
- if (xi2GetButtonState(xiDeviceEvent, 6))
+ if (xiDeviceEvent->detail == 6)
angleDelta.setX(120);
- if (xi2GetButtonState(xiDeviceEvent, 7))
+ else if (xiDeviceEvent->detail == 7)
angleDelta.setX(-120);
}
if (!angleDelta.isNull()) {