diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2019-05-31 08:38:16 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-06-16 22:06:56 +0200 |
commit | 6589f2ed0cf78c9b8a5bdffcdc458dc40a974c60 (patch) | |
tree | 61f29061a4cbaf925ef0ab7ba9fafc1db9ee4ef3 /src/testlib/qtesttouch.h | |
parent | 0a2e3ce85ce788b8a07380a458faf4ed3817d0c0 (diff) |
Introduce QInputDevice hierarchy; replace QTouchDevice
We have seen during the Qt 5 series that QMouseEvent::source() does
not provide enough information: if it is synthesized, it could have
come from any device for which mouse events are synthesized, not only
from a touchscreen. By providing in every QInputEvent as complete
information about the actual source device as possible, we will enable
very fine-tuned behavior in the object that handles each event.
Further, we would like to support multiple keyboards, pointing devices,
and named groups of devices that are known as "seats" in Wayland.
In Qt 5, QPA plugins registered each touchscreen as it was discovered.
Now we extend this pattern to all input devices. This new requirement
can be implemented gradually; for now, if a QTWSI input event is
received wtihout a device pointer, a default "core" device will be
created on-the-fly, and a warning emitted.
In Qt 5, QTouchEvent::TouchPoint::id() was forced to be unique even when
multiple devices were in use simultaneously. Now that each event
identifies the device it came from, this hack is no longer needed.
A stub of the new QPointerEvent is added; it will be developed further
in subsequent patches.
[ChangeLog][QtGui][QInputEvent] Every QInputEvent now carries a pointer
to an instance of QInputDevice, or the subclass QPointingDevice in case
of mouse, touch and tablet events. Each platform plugin is expected to
create the device instances, register them, and provide valid pointers
with all input events. If this is not done, warnings are emitted and
default devices are created as necessary. When the device has accurate
information, it provides the opportunity to fine-tune behavior depending
on device type and capabilities: for example if a QMouseEvent is
synthesized from a touchscreen, the recipient can see which touchscreen
it came from. Each device also has a seatName to distinguish users on
multi-user windowing systems. Touchpoint IDs are no longer unique on
their own, but the combination of ID and device is.
Fixes: QTBUG-46412
Fixes: QTBUG-72167
Task-number: QTBUG-69433
Task-number: QTBUG-52430
Change-Id: I933fb2b86182efa722037b7a33e404c5daf5292a
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/testlib/qtesttouch.h')
-rw-r--r-- | src/testlib/qtesttouch.h | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/testlib/qtesttouch.h b/src/testlib/qtesttouch.h index a38e055882..6db7fb52ec 100644 --- a/src/testlib/qtesttouch.h +++ b/src/testlib/qtesttouch.h @@ -51,22 +51,25 @@ #include <QtTest/qtestspontaneevent.h> #include <QtCore/qmap.h> #include <QtGui/qevent.h> +#include <QtGui/qpointingdevice.h> #include <QtGui/qwindow.h> -#include <QtGui/qtouchdevice.h> +#include <QtGui/qpointingdevice.h> #ifdef QT_WIDGETS_LIB #include <QtWidgets/qwidget.h> #endif QT_BEGIN_NAMESPACE -Q_GUI_EXPORT void qt_handleTouchEvent(QWindow *w, QTouchDevice *device, +Q_GUI_EXPORT void qt_handleTouchEvent(QWindow *w, const QPointingDevice *device, const QList<QTouchEvent::TouchPoint> &points, Qt::KeyboardModifiers mods = Qt::NoModifier); namespace QTest { - Q_GUI_EXPORT QTouchDevice * createTouchDevice(QTouchDevice::DeviceType devType = QTouchDevice::TouchScreen); + Q_GUI_EXPORT QPointingDevice * createTouchDevice(QInputDevice::DeviceType devType = QInputDevice::DeviceType::TouchScreen, + QInputDevice::Capabilities caps = QInputDevice::Capability::Position); + class QTouchEventSequence { @@ -151,12 +154,12 @@ namespace QTest private: #ifdef QT_WIDGETS_LIB - QTouchEventSequence(QWidget *widget, QTouchDevice *aDevice, bool autoCommit) + QTouchEventSequence(QWidget *widget, QPointingDevice *aDevice, bool autoCommit) : targetWidget(widget), targetWindow(nullptr), device(aDevice), commitWhenDestroyed(autoCommit) { } #endif - QTouchEventSequence(QWindow *window, QTouchDevice *aDevice, bool autoCommit) + QTouchEventSequence(QWindow *window, QPointingDevice *aDevice, bool autoCommit) : #ifdef QT_WIDGETS_LIB targetWidget(nullptr), @@ -204,18 +207,18 @@ private: QWidget *targetWidget; #endif QWindow *targetWindow; - QTouchDevice *device; + QPointingDevice *device; bool commitWhenDestroyed; #if defined(QT_WIDGETS_LIB) || defined(Q_CLANG_QDOC) - friend QTouchEventSequence touchEvent(QWidget *widget, QTouchDevice *device, bool autoCommit); + friend QTouchEventSequence touchEvent(QWidget *widget, QPointingDevice *device, bool autoCommit); #endif - friend QTouchEventSequence touchEvent(QWindow *window, QTouchDevice *device, bool autoCommit); + friend QTouchEventSequence touchEvent(QWindow *window, QPointingDevice *device, bool autoCommit); }; #if defined(QT_WIDGETS_LIB) || defined(Q_CLANG_QDOC) inline QTouchEventSequence touchEvent(QWidget *widget, - QTouchDevice *device, + QPointingDevice *device, bool autoCommit = true) { return QTouchEventSequence(widget, device, autoCommit); @@ -223,7 +226,7 @@ private: #endif inline QTouchEventSequence touchEvent(QWindow *window, - QTouchDevice *device, + QPointingDevice *device, bool autoCommit = true) { return QTouchEventSequence(window, device, autoCommit); |