From 29fda24ca8abdf7179139f1f7f74f9147edddfac Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 22 Jul 2013 09:20:44 +0200 Subject: [PATCH] added maximumTouchPoints to QTouchDevice This was missing information which the driver can provide. Change-Id: I2574745635d6fdf608bc5617999aec46d9312c09 Reviewed-by: Friedemann Kleint --- src/gui/kernel/qtouchdevice.cpp | 19 +++++++++++++++++++ src/gui/kernel/qtouchdevice.h | 2 ++ src/gui/kernel/qtouchdevice_p.h | 4 +++- .../platforms/xcb/qxcbconnection_xi2.cpp | 5 +++-- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qtouchdevice.cpp b/src/gui/kernel/qtouchdevice.cpp index 02c6dd9efc..3ad4b4161e 100644 --- a/src/gui/kernel/qtouchdevice.cpp +++ b/src/gui/kernel/qtouchdevice.cpp @@ -139,6 +139,16 @@ QTouchDevice::Capabilities QTouchDevice::capabilities() const return d->caps; } +/*! + Returns the maximum number of simultaneous touch points (fingers) that + can be detected. + \since 5.2 + */ +int QTouchDevice::maximumTouchPoints() const +{ + return d->maxTouchPoints; +} + /*! Returns the touch device name. @@ -168,6 +178,15 @@ void QTouchDevice::setCapabilities(Capabilities caps) d->caps = caps; } +/*! + Sets the maximum number of simultaneous touchpoints \a max + supported by the device and its driver. + */ +void QTouchDevice::setMaximumTouchPoints(int max) +{ + d->maxTouchPoints = max; +} + /*! Sets the \a name (a unique identifier) for the device. In most systems it is enough to leave this unset and keep the default empty name. This identifier diff --git a/src/gui/kernel/qtouchdevice.h b/src/gui/kernel/qtouchdevice.h index 312bdce3e6..6aca93907c 100644 --- a/src/gui/kernel/qtouchdevice.h +++ b/src/gui/kernel/qtouchdevice.h @@ -75,10 +75,12 @@ public: QString name() const; DeviceType type() const; Capabilities capabilities() const; + int maximumTouchPoints() const; void setName(const QString &name); void setType(DeviceType devType); void setCapabilities(Capabilities caps); + void setMaximumTouchPoints(int max); private: QTouchDevicePrivate *d; diff --git a/src/gui/kernel/qtouchdevice_p.h b/src/gui/kernel/qtouchdevice_p.h index 435f8a5c37..fb87f49736 100644 --- a/src/gui/kernel/qtouchdevice_p.h +++ b/src/gui/kernel/qtouchdevice_p.h @@ -64,12 +64,14 @@ class QTouchDevicePrivate public: QTouchDevicePrivate() : type(QTouchDevice::TouchScreen), - caps(QTouchDevice::Position) + caps(QTouchDevice::Position), + maxTouchPoints(1) { } QTouchDevice::DeviceType type; QTouchDevice::Capabilities caps; QString name; + int maxTouchPoints; static void registerDevice(QTouchDevice *dev); static bool isRegistered(QTouchDevice *dev); diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index b95d276c18..35c7af23a9 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -210,6 +210,7 @@ XInput2DeviceData *QXcbConnection::deviceForId(int id) #ifdef XCB_USE_XINPUT22 case XITouchClass: { XITouchClassInfo *tci = reinterpret_cast(classinfo); + dev->qtTouchDevice->setMaximumTouchPoints(tci->num_touches); switch (tci->mode) { case XIModeRelative: dev->qtTouchDevice->setType(QTouchDevice::TouchPad); @@ -236,8 +237,8 @@ XInput2DeviceData *QXcbConnection::deviceForId(int id) if (caps != 0) QWindowSystemInterface::registerTouchDevice(dev->qtTouchDevice); #ifdef XI2_DEBUG - qDebug("registered new device %s with %d classes", - dev->xiDeviceInfo->name, dev->xiDeviceInfo->num_classes); + qDebug("registered new device %s with %d classes and %d maximum touch points", + dev->xiDeviceInfo->name, dev->xiDeviceInfo->num_classes, dev->qtTouchDevice->maximumTouchPoints()); #endif m_touchDevices[id] = dev; }