From 83729ad7a1e2d9c75ddf7238ab7c91b514dcebcf Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 12 Sep 2017 16:39:56 +0200 Subject: make the QTouchDevice available in each QNativeGestureEvent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QtQuick is beginning to have a use for this, to distinguish native gestures which come from actual trackpad rather than from the "core pointer". It might as well use a real device ID instead of making one up, as it has to do for the core pointer. So far on macOS, the device ID isn't a real one; but that can be fixed, as the qCDebug lines demonstrate (different trackpads have different IDs). Change-Id: I5841deb1c4cc0b77a3b1df70904f70b3d2d71853 Reviewed-by: Shawn Rutledge Reviewed-by: Jan Arve Sæther --- src/gui/kernel/qevent.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/gui/kernel/qevent.cpp') diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 5000cc35dd..df093ddbf6 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -40,6 +40,7 @@ #include "qevent.h" #include "qcursor.h" #include "private/qguiapplication_p.h" +#include "private/qtouchdevice_p.h" #include "qpa/qplatformintegration.h" #include "qpa/qplatformdrag.h" #include "private/qevent_p.h" @@ -2765,13 +2766,19 @@ Qt::MouseButtons QTabletEvent::buttons() const \a realValue is the \macos event parameter, \a sequenceId and \a intValue are the Windows event parameters. */ -QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QPointF &localPos, const QPointF &windowPos, +QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QTouchDevice *dev, const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos, qreal realValue, ulong sequenceId, quint64 intValue) : QInputEvent(QEvent::NativeGesture), mGestureType(type), + mTouchDeviceId(QTouchDevicePrivate::get(const_cast(dev))->id), mLocalPos(localPos), mWindowPos(windowPos), mScreenPos(screenPos), mRealValue(realValue), mSequenceId(sequenceId), mIntValue(intValue) { } +const QTouchDevice *QNativeGestureEvent::device() const +{ + return QTouchDevicePrivate::deviceById(mTouchDeviceId); +} + /*! \fn QNativeGestureEvent::gestureType() const \since 5.2 -- cgit v1.2.3 From ce019efb5cfcc0bce516a761be4295c568994a31 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 22 Sep 2017 09:42:48 +0200 Subject: add back the device-less QNativeGestureEvent (deprecated) It was an oversight in 83729ad7a1e2d9c75ddf7238ab7c91b514dcebcf that this constructor is still in use in other modules. And in fact we cannot remove public constructors without deprecating them first. Task-number: QTBUG-63355 Change-Id: I64dbf9bc54c0bf6be7157f047b548d3b2c5bc2ed Reviewed-by: Simon Hausmann --- src/gui/kernel/qevent.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/gui/kernel/qevent.cpp') diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index df093ddbf6..7b1eb277b2 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -2757,6 +2757,18 @@ Qt::MouseButtons QTabletEvent::buttons() const \sa Qt::NativeGestureType, QGestureEvent */ +/*! + \deprecated The QTouchDevice parameter is now required +*/ +#if QT_DEPRECATED_SINCE(5, 10) +QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QPointF &localPos, const QPointF &windowPos, + const QPointF &screenPos, qreal realValue, ulong sequenceId, quint64 intValue) + : QInputEvent(QEvent::NativeGesture), mGestureType(type), mTouchDeviceId(255), + mLocalPos(localPos), mWindowPos(windowPos), mScreenPos(screenPos), mRealValue(realValue), + mSequenceId(sequenceId), mIntValue(intValue) +{ } +#endif + /*! Constructs a native gesture event of type \a type. -- cgit v1.2.3 From 7896efdd9f51b7defa02e73303f8aa03cc7f3044 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 25 Sep 2017 14:38:15 +0200 Subject: QNativeGestureEvent: Fix documentation Fix qdoc-warnings: src/gui/kernel/qevent.cpp:2772: warning: Undocumented parameter 'dev' in QNativeGestureEvent::QNativeGestureEvent() src/gui/kernel/qevent.cpp:2794: warning: No documentation for 'QNativeGestureEvent::device()' Change-Id: I845b0925ad4f1d8602455444ebbd4ec6320ebae7 Reviewed-by: Shawn Rutledge --- src/gui/kernel/qevent.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/gui/kernel/qevent.cpp') diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 7b1eb277b2..55339cac8c 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -2770,22 +2770,29 @@ QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QPoin #endif /*! - Constructs a native gesture event of type \a type. + Constructs a native gesture event of type \a type originating from \a device. The points \a localPos, \a windowPos and \a screenPos specify the gesture position relative to the receiving widget or item, window, and screen, respectively. \a realValue is the \macos event parameter, \a sequenceId and \a intValue are the Windows event parameters. + \since 5.10 */ -QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QTouchDevice *dev, const QPointF &localPos, const QPointF &windowPos, +QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QTouchDevice *device, const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos, qreal realValue, ulong sequenceId, quint64 intValue) : QInputEvent(QEvent::NativeGesture), mGestureType(type), - mTouchDeviceId(QTouchDevicePrivate::get(const_cast(dev))->id), + mTouchDeviceId(QTouchDevicePrivate::get(const_cast(device))->id), mLocalPos(localPos), mWindowPos(windowPos), mScreenPos(screenPos), mRealValue(realValue), mSequenceId(sequenceId), mIntValue(intValue) { } +/*! + \since 5.10 + + Returns the device. +*/ + const QTouchDevice *QNativeGestureEvent::device() const { return QTouchDevicePrivate::deviceById(mTouchDeviceId); -- cgit v1.2.3