summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2011-09-20 12:17:28 +0200
committerQt by Nokia <qt-info@nokia.com>2011-09-20 17:37:18 +0200
commit252d1b34b26779cbc1ac269f4af7fdb1f27038ef (patch)
tree8143ba5f6b115172a09a1ff7da160ae901cc04ed /src/gui
parentd5f12b898b8480c891382c54672422c50218751a (diff)
QWindowSystemInterface: Fix wrong mapping of coordinates.
QTouchEvent::TouchPoint assumes the rect() is in local coordinates, whereas QWindowSystemInterface::TouchPoint uses screen coordinates. We must therefore use QWindowSystemInterface::TouchPoint::area as the screenRect() rather that the rect() and then use the screen coordinate to calculate the local coordinate by using mapFromGlobal. Change-Id: If7a52f5668c3938f46bdd38a5ea82b5313d6b626 Reviewed-on: http://codereview.qt-project.org/5253 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Bjørn Erik Nilsen <bjorn.nilsen@nokia.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qwindowsysteminterface_qpa.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.cpp b/src/gui/kernel/qwindowsysteminterface_qpa.cpp
index d862d05baa..898de3a425 100644
--- a/src/gui/kernel/qwindowsysteminterface_qpa.cpp
+++ b/src/gui/kernel/qwindowsysteminterface_qpa.cpp
@@ -230,8 +230,20 @@ void QWindowSystemInterface::handleTouchEvent(QWindow *tlw, ulong timestamp, QEv
state |= Qt::TouchPointPrimary;
}
p.setState(state);
- p.setRect(point->area);
- p.setScreenPos(point->area.center());
+
+ const QPointF screenPos = point->area.center();
+ p.setScreenPos(screenPos);
+ p.setScreenRect(point->area);
+
+ // Map screen pos to local (QWindow) coordinates and preserve sub-pixel resolution.
+ const QPointF delta = screenPos - screenPos.toPoint();
+ const QPointF localPos = tlw->mapFromGlobal(screenPos.toPoint()) + delta;
+ p.setPos(localPos);
+
+ QRectF rect(0, 0, point->area.width(), point->area.height());
+ rect.moveCenter(localPos);
+ p.setRect(rect);
+
p.setNormalizedPos(point->normalPosition);
touchPoints.append(p);