summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@digia.com>2014-08-20 12:43:52 +0200
committerAllan Sandfeld Jensen <allan.jensen@digia.com>2014-08-21 17:31:40 +0200
commitd88de0452a8b5c34a860405d89a43d05447f061e (patch)
tree789b27eaf7cdda8e8ad7b15e3bb82f27471a0e5b /src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
parentb78e81f7c23a557a31ad649b33d85eed9a697281 (diff)
xcb: set up touch devices even if debug is not turned on
59ba84d31cf17d86e615e2958fece6f6e0bbefe2 introduced a mistake. It's necessary to populate the device data structure even if we are not going to log anything. Now the accessor is renamed to touchDeviceForId and the struct is renamed to XInput2TouchDeviceData to make it more clear that it is only for touch devices. Change-Id: Iaa3cce2d6cae250318f5a200becb9de9626b6437 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbconnection_xi2.cpp')
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection_xi2.cpp40
1 files changed, 22 insertions, 18 deletions
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) {