diff options
author | Shawn Rutledge <shawn.rutledge@digia.com> | 2014-08-20 12:43:52 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2014-08-21 17:31:40 +0200 |
commit | d88de0452a8b5c34a860405d89a43d05447f061e (patch) | |
tree | 789b27eaf7cdda8e8ad7b15e3bb82f27471a0e5b /src | |
parent | b78e81f7c23a557a31ad649b33d85eed9a697281 (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')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbconnection.h | 6 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 40 |
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) { |