summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2016-12-06 14:48:44 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2016-12-09 13:44:55 +0000
commit201f89f463ae82fe8e9239d7312907062e9a8d15 (patch)
treebff62d570082aa6e096123a85399517e9acc5973 /src/widgets
parenta30fca8711374edfefb2085aaa64ac98971b7c40 (diff)
QTouchEvent::TouchPoint: replace ellipse diameters with QSizeF
It makes assignment a bit more succinct and efficient since they are usually set together. Since we store the diameters and the points separately, we no longer need to worry about updating rects by moving their centers. QGuiApplication and QApplication don't need to alter the diameters: they are set once when the event is constructed. Also fix the initialization of pressure and rotation: 418b6f6899ee414aff29c91a4ae17eed8791a617 did it by casting a double to qreal, whereas a plain integer constant will be auto-converted by the compiler anyway. Change-Id: Ib9956d2def21278b8ae042147d917da156e77e52 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/kernel/qapplication.cpp14
1 files changed, 3 insertions, 11 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 9588b631a0..1bdfcfada2 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -3550,11 +3550,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
touchEvent->setTarget(widget);
for (int i = 0; i < touchEvent->_touchPoints.size(); ++i) {
QTouchEvent::TouchPoint &pt = touchEvent->_touchPoints[i];
- QRectF rect = pt.rect();
- rect.translate(offset);
- pt.d->pos = rect.center();
- pt.d->verticalDiameter = rect.height();
- pt.d->horizontalDiameter = rect.width();
+ pt.d->pos = pt.pos() + offset;
pt.d->startPos = pt.startPos() + offset;
pt.d->lastPos = pt.lastPos() + offset;
}
@@ -4251,14 +4247,10 @@ bool QApplicationPrivate::updateTouchPointsForWidget(QWidget *widget, QTouchEven
QTouchEvent::TouchPoint &touchPoint = touchEvent->_touchPoints[i];
// preserve the sub-pixel resolution
- QRectF rect = touchPoint.screenRect();
- const QPointF screenPos = rect.center();
+ const QPointF screenPos = touchPoint.screenRect().center();
const QPointF delta = screenPos - screenPos.toPoint();
- rect.moveCenter(widget->mapFromGlobal(screenPos.toPoint()) + delta);
- touchPoint.d->pos = rect.center();
- touchPoint.d->verticalDiameter = rect.height();
- touchPoint.d->horizontalDiameter = rect.width();
+ touchPoint.d->pos = widget->mapFromGlobal(screenPos.toPoint()) + delta;
touchPoint.d->startPos = widget->mapFromGlobal(touchPoint.startScreenPos().toPoint()) + delta;
touchPoint.d->lastPos = widget->mapFromGlobal(touchPoint.lastScreenPos().toPoint()) + delta;