summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/kernel
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-03-27 16:06:11 +0000
committerShawn Rutledge <shawn.rutledge@qt.io>2020-07-10 14:32:56 +0200
commit4e400369c08db251cd489fec1229398c224d02b4 (patch)
tree6279489dce7b0469d590461798deccf5d1193e29 /tests/auto/widgets/kernel
parent773a6bffd78b363577d27604e17f4ee08ff07e77 (diff)
Refactor pointer event hierarchy
Some goals that have hopefully been achieved are: - make QPointerEvent and QEventPoint resemble their Qt Quick counterparts to such an extent that we can remove those wrappers and go back to delivering the original events in Qt Quick - make QEventPoint much smaller than QTouchEvent::TouchPoint, with no pimpl - remove most public setters - reduce the usage of complex constructors that take many arguments - don't repeat ourselves: move accessors and storage upwards rather than having redundant ones in subclasses - standardize the set of accessors in QPointerEvent - maintain source compatibility as much as possible: do not require modifying event-handling code in any QWidget subclass To avoid public setters we now introduce a few QMutable* subclasses. This is a bit like the Builder pattern except that it doesn't involve constructing a separate disposable object: the main event type can be cast to the mutable type at any time to enable modifications, iff the code is linked with gui-private. Therefore event classes can have less-"complete" constructors, because internal Qt code can use setters the same way it could use the ones in QTouchEvent before; and the event classes don't need many friends. Even some read-accessors can be kept private unless we are sure we want to expose them. Task-number: QTBUG-46266 Fixes: QTBUG-72173 Change-Id: I740e4e40165b7bc41223d38b200bbc2b403e07b6 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto/widgets/kernel')
-rw-r--r--tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
index a4a8eb956c..8a2297c359 100644
--- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
@@ -57,6 +57,7 @@
#include <qpa/qwindowsysteminterface.h>
#include <qpa/qwindowsysteminterface_p.h>
+#include <private/qevent_p.h>
#include <private/qhighdpiscaling_p.h>
#include <algorithm>
@@ -1900,15 +1901,6 @@ void tst_QApplication::touchEventPropagation()
int argc = 1;
QApplication app(argc, &argv0);
- QList<QTouchEvent::TouchPoint> pressedTouchPoints;
- QTouchEvent::TouchPoint press(0);
- press.setState(Qt::TouchPointPressed);
- pressedTouchPoints << press;
-
- QList<QTouchEvent::TouchPoint> releasedTouchPoints;
- QTouchEvent::TouchPoint release(0);
- release.setState(Qt::TouchPointReleased);
- releasedTouchPoints << release;
QPointingDevice *device = QTest::createTouchDevice();
@@ -1927,8 +1919,10 @@ void tst_QApplication::touchEventPropagation()
// we must ensure there is a screen position in the TouchPoint that maps to a local 0, 0.
const QPoint deviceGlobalPos =
QHighDpi::toNativePixels(window.mapToGlobal(QPoint(0, 0)), window.windowHandle()->screen());
- pressedTouchPoints[0].setScreenPos(deviceGlobalPos);
- releasedTouchPoints[0].setScreenPos(deviceGlobalPos);
+ auto pressedTouchPoints = QList<QEventPoint>() <<
+ QEventPoint(0, QEventPoint::State::Pressed, QPointF(), deviceGlobalPos);
+ auto releasedTouchPoints = QList<QEventPoint>() <<
+ QEventPoint(0, QEventPoint::State::Released, QPointF(), deviceGlobalPos);
QWindowSystemInterface::handleTouchEvent(handle,
0,
@@ -1985,8 +1979,10 @@ void tst_QApplication::touchEventPropagation()
QVERIFY(QTest::qWaitForWindowExposed(&window));
const QPoint deviceGlobalPos =
QHighDpi::toNativePixels(window.mapToGlobal(QPoint(50, 150)), window.windowHandle()->screen());
- pressedTouchPoints[0].setScreenPos(deviceGlobalPos);
- releasedTouchPoints[0].setScreenPos(deviceGlobalPos);
+ auto pressedTouchPoints = QList<QEventPoint>() <<
+ QEventPoint(0, QEventPoint::State::Pressed, QPointF(), deviceGlobalPos);
+ auto releasedTouchPoints = QList<QEventPoint>() <<
+ QEventPoint(0, QEventPoint::State::Released, QPointF(), deviceGlobalPos);
QWindowSystemInterface::handleTouchEvent(handle,
0,