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>
This commit is contained in:
Bjørn Erik Nilsen 2011-09-20 12:17:28 +02:00 committed by Qt by Nokia
parent d5f12b898b
commit 252d1b34b2

View File

@ -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);