summaryrefslogtreecommitdiffstats
path: root/src/testlib/qtesttouch.h
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>2011-12-10 16:30:18 +0200
committerQt by Nokia <qt-info@nokia.com>2011-12-14 13:17:19 +0100
commit3064c1bc8cc04a40f6e468033d73823987687d40 (patch)
treec24b66cb19bc9419de86bc355f71793bb4f80da8 /src/testlib/qtesttouch.h
parent14d9a2b06c58f544f0db13267091cf94ed0d2e97 (diff)
Remove redundant touch processing in QtGui and widgets.
The duplicated hash tables in QGuiApplicationPrivate and QApplicationPrivate are now unified into one single hash table in QGuiApplicationPrivate. This also reduced the number of lookups. The extra processing needed to keep the touch points' first/lastPos values in sync is now done only once, in QGuiApplication. This eliminates the performance penalty (for widget-based apps) that was introduced during the QPA migration. As an added bonus the patch adds support for touch events arriving simultaenously from multiple devices. This was broken before: As there is no guarantee that two devices/drivers will not send touch points with the same ID, using structures with only the ID as key is wrong. The proper key is composed of the device ID (that is, a QTouchDevice pointer) and the touch point ID. The exported internal function qt_translateRawTouchEvent() has been removed. This function cannot work properly in the QPA world: It injected touches into the widget subsystem (QApplication) only which is wrong, and would result in half-filled touch events due to not routing the injected data through QGuiApplication. Autotests using this function are migrated to QWindowSystemInterface::handleTouchEvent(). Change-Id: I7632781d77f9e0ac4626fd7c9933511c94492156 Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src/testlib/qtesttouch.h')
-rw-r--r--src/testlib/qtesttouch.h56
1 files changed, 26 insertions, 30 deletions
diff --git a/src/testlib/qtesttouch.h b/src/testlib/qtesttouch.h
index 57085adb8b..3763a9a500 100644
--- a/src/testlib/qtesttouch.h
+++ b/src/testlib/qtesttouch.h
@@ -62,13 +62,6 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Test)
-#ifdef QT_WIDGETS_LIB
-extern Q_GUI_EXPORT void qt_translateRawTouchEvent(QWidget *window,
- QTouchDevice *device,
- const QList<QTouchEvent::TouchPoint> &touchPoints,
- ulong timestamp);
-#endif
-
namespace QTest
{
@@ -137,19 +130,43 @@ namespace QTest
if (targetWindow)
{
QWindowSystemInterface::handleTouchEvent(targetWindow, device, touchPointList(points.values()));
- QTest::qWait(10);
}
#ifdef QT_WIDGETS_LIB
else if (targetWidget)
{
- qt_translateRawTouchEvent(targetWidget, device, points.values(), 0);
+ QWindowSystemInterface::handleTouchEvent(targetWidget->windowHandle(), device, touchPointList(points.values()));
}
#endif
}
+ QCoreApplication::processEvents();
previousPoints = points;
points.clear();
}
+ static QWindowSystemInterface::TouchPoint touchPoint(const QTouchEvent::TouchPoint& pt)
+ {
+ QWindowSystemInterface::TouchPoint p;
+ p.id = pt.id();
+ p.flags = pt.flags();
+ p.normalPosition = pt.normalizedPos();
+ p.area = pt.screenRect();
+ p.pressure = pt.pressure();
+ p.state = pt.state();
+ p.velocity = pt.velocity();
+ p.rawPositions = pt.rawScreenPositions();
+ return p;
+ }
+ static QList<struct QWindowSystemInterface::TouchPoint> touchPointList(const QList<QTouchEvent::TouchPoint>& pointList)
+ {
+ QList<struct QWindowSystemInterface::TouchPoint> newList;
+
+ Q_FOREACH (QTouchEvent::TouchPoint p, pointList)
+ {
+ newList.append(touchPoint(p));
+ }
+ return newList;
+ }
+
private:
#ifdef QT_WIDGETS_LIB
QTouchEventSequence(QWidget *widget, QTouchDevice *aDevice)
@@ -198,27 +215,6 @@ namespace QTest
return window->mapToGlobal(pt);
return targetWindow ? targetWindow->mapToGlobal(pt) : pt;
}
- QWindowSystemInterface::TouchPoint touchPoint(const QTouchEvent::TouchPoint& pt)
- {
- QWindowSystemInterface::TouchPoint p;
- p.id = pt.id();
- p.flags = pt.flags();
- p.normalPosition = pt.screenRect().topLeft();
- p.area = pt.screenRect();
- p.pressure = pt.pressure();
- p.state = pt.state();
- return p;
- }
- QList<struct QWindowSystemInterface::TouchPoint> touchPointList(const QList<QTouchEvent::TouchPoint>& pointList)
- {
- QList<struct QWindowSystemInterface::TouchPoint> newList;
-
- Q_FOREACH (QTouchEvent::TouchPoint p, pointList)
- {
- newList.append(touchPoint(p));
- }
- return newList;
- }
QMap<int, QTouchEvent::TouchPoint> previousPoints;
QMap<int, QTouchEvent::TouchPoint> points;