xcb: set up touch devices even if debug is not turned on

59ba84d31c 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>
bb10
Shawn Rutledge 2014-08-20 12:43:52 +02:00 committed by Allan Sandfeld Jensen
parent b78e81f7c2
commit d88de0452a
2 changed files with 25 additions and 21 deletions

View File

@ -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;

View File

@ -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) {