summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/xcb')
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.h6
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection_xi2.cpp40
2 files changed, 25 insertions, 21 deletions
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h
index 9816d221a7..01dd048ea3 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.h
+++ b/src/plugins/platforms/xcb/qxcbconnection.h
@@ -74,7 +74,7 @@
#define XCB_USE_XINPUT22 // XI 2.2 adds multi-point touch support
#endif
#endif
-struct XInput2DeviceData;
+struct XInput2TouchDeviceData;
#endif
struct xcb_randr_get_output_info_reply_t;
@@ -508,7 +508,7 @@ private:
void initializeXInput2();
void finalizeXInput2();
void xi2SetupDevices();
- XInput2DeviceData *deviceForId(int id);
+ XInput2TouchDeviceData *touchDeviceForId(int id);
void xi2HandleEvent(xcb_ge_event_t *event);
void xi2HandleHierachyEvent(void *event);
int m_xiOpCode, m_xiEventBase, m_xiErrorBase;
@@ -583,7 +583,7 @@ private:
QXcbEventReader *m_reader;
#if defined(XCB_USE_XINPUT2)
QHash<int, QWindowSystemInterface::TouchPoint> m_touchPoints;
- QHash<int, XInput2DeviceData*> m_touchDevices;
+ QHash<int, XInput2TouchDeviceData*> m_touchDevices;
#endif
#if defined(XCB_USE_EGL)
void *m_egl_display;
diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
index 7c5db7c6e5..af4ed8e6e6 100644
--- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
@@ -53,8 +53,8 @@
#include <X11/extensions/XI2proto.h>
#define FINGER_MAX_WIDTH_MM 10
-struct XInput2DeviceData {
- XInput2DeviceData()
+struct XInput2TouchDeviceData {
+ XInput2TouchDeviceData()
: xiDeviceInfo(0)
, qtTouchDevice(0)
{
@@ -214,17 +214,21 @@ void QXcbConnection::xi2SetupDevices()
}
#endif
- if (!isTablet && lcQpaXInputDevices().isDebugEnabled()) {
- XInput2DeviceData *dev = deviceForId(devices[i].deviceid);
- if (dev && dev->qtTouchDevice->type() == QTouchDevice::TouchScreen)
- qCDebug(lcQpaXInputDevices, " it's a touchscreen with type %d capabilities 0x%X max touch points %d",
- dev->qtTouchDevice->type(), (unsigned int)dev->qtTouchDevice->capabilities(),
- dev->qtTouchDevice->maximumTouchPoints());
- else if (dev && dev->qtTouchDevice->type() == QTouchDevice::TouchPad)
- qCDebug(lcQpaXInputDevices, " it's a touchpad with type %d capabilities 0x%X max touch points %d size %f x %f",
- dev->qtTouchDevice->type(), (unsigned int)dev->qtTouchDevice->capabilities(),
- dev->qtTouchDevice->maximumTouchPoints(),
- dev->size.width(), dev->size.height());
+ if (!isTablet) {
+ // touchDeviceForId populates XInput2DeviceData the first time it is called
+ // with a new deviceId. On subsequent calls it will return the cached object.
+ XInput2TouchDeviceData *dev = touchDeviceForId(devices[i].deviceid);
+ if (dev && lcQpaXInputDevices().isDebugEnabled()) {
+ if (dev->qtTouchDevice->type() == QTouchDevice::TouchScreen)
+ qCDebug(lcQpaXInputDevices, " it's a touchscreen with type %d capabilities 0x%X max touch points %d",
+ dev->qtTouchDevice->type(), (unsigned int)dev->qtTouchDevice->capabilities(),
+ dev->qtTouchDevice->maximumTouchPoints());
+ else if (dev->qtTouchDevice->type() == QTouchDevice::TouchPad)
+ qCDebug(lcQpaXInputDevices, " it's a touchpad with type %d capabilities 0x%X max touch points %d size %f x %f",
+ dev->qtTouchDevice->type(), (unsigned int)dev->qtTouchDevice->capabilities(),
+ dev->qtTouchDevice->maximumTouchPoints(),
+ dev->size.width(), dev->size.height());
+ }
}
}
XIFreeDeviceInfo(devices);
@@ -232,7 +236,7 @@ void QXcbConnection::xi2SetupDevices()
void QXcbConnection::finalizeXInput2()
{
- foreach (XInput2DeviceData *dev, m_touchDevices) {
+ foreach (XInput2TouchDeviceData *dev, m_touchDevices) {
if (dev->xiDeviceInfo)
XIFreeDeviceInfo(dev->xiDeviceInfo);
delete dev;
@@ -328,13 +332,13 @@ void QXcbConnection::xi2Select(xcb_window_t window)
}
}
-XInput2DeviceData *QXcbConnection::deviceForId(int id)
+XInput2TouchDeviceData *QXcbConnection::touchDeviceForId(int id)
{
- XInput2DeviceData *dev = m_touchDevices[id];
+ XInput2TouchDeviceData *dev = m_touchDevices[id];
if (!dev) {
int unused = 0;
QTouchDevice::Capabilities caps = 0;
- dev = new XInput2DeviceData;
+ dev = new XInput2TouchDeviceData;
dev->xiDeviceInfo = XIQueryDevice(static_cast<Display *>(m_xlib_display), id, &unused);
int type = -1;
int maxTouchPoints = 1;
@@ -456,7 +460,7 @@ void QXcbConnection::xi2HandleEvent(xcb_ge_event_t *event)
fixed1616ToReal(xiDeviceEvent->root_x), fixed1616ToReal(xiDeviceEvent->root_y) );
if (QXcbWindow *platformWindow = platformWindowFromId(xiDeviceEvent->event)) {
- XInput2DeviceData *dev = deviceForId(xiDeviceEvent->sourceid);
+ XInput2TouchDeviceData *dev = touchDeviceForId(xiDeviceEvent->sourceid);
Q_ASSERT(dev);
const bool firstTouch = m_touchPoints.isEmpty();
if (xiEvent->evtype == XI_TouchBegin) {