Remove more calls to deprecated TouchPoint functions
Followup to ed3ed0b9db97a8fab0c03add23228b6b0a96f171 68916fede41d1eca5d07eb6b1db518d41a007616 and 3c159957f863cf8d367a9261e7016e52cd0348c1. In QWindowSystemInterfacePrivate::fromNativeTouchPoints() and QWindowSystemInterfacePrivate::toNativeTouchPoints() we continue using struct TouchPoint's QRectF area as storage for the screen position + ellipse diameters; as the comment says, this is _unrotated_, meaning that rotation is stored separately, and area should not be construed as the bounding box of the rotated ellipse. (In Qt 6 we can make the QPA touchpoint look the same as the QTouchEvent::TouchPoint to eliminate the need to calculate the center of the rect.) In QGraphicsScenePrivate::updateTouchPointsForItem(), setRect() sets the position and the ellipse diameters, but the latter is redundant because the purpose of this function is to localize a touchpoint to the coordinate system of a particular QGraphicsItem. Ellipse diameters should stay the same. In QApplicationPrivate::updateTouchPointsForWidget(), as in QGraphicsScene, we are localizing touchpoints to a widget and to the screen that the widget is shown on, so only the position needs to be set, while preserving the sub-pixel resolution that mapFromGlobal(QPoint) loses. Fixes: QTBUG-83403 Change-Id: I61d29e14cbe38567767b164af6ae895082c5e1a1 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
7cd2d2b751
commit
cf4a8b12fa
@ -687,9 +687,8 @@ QList<QTouchEvent::TouchPoint>
|
||||
states |= point->state;
|
||||
p.setState(point->state);
|
||||
|
||||
const QPointF screenPos = point->area.center();
|
||||
p.setScreenPos(QHighDpi::fromNativePixels(screenPos, window));
|
||||
p.setScreenRect(QHighDpi::fromNativePixels(point->area, window));
|
||||
p.setScreenPos(QHighDpi::fromNativePixels(point->area.center(), window));
|
||||
p.setEllipseDiameters(point->area.size());
|
||||
|
||||
// The local pos and rect are not set, they will be calculated
|
||||
// when the event gets processed by QGuiApplication.
|
||||
@ -750,7 +749,9 @@ QList<QWindowSystemInterface::TouchPoint>
|
||||
p.id = pt.id();
|
||||
p.flags = pt.flags();
|
||||
p.normalPosition = QHighDpi::toNativeLocalPosition(pt.normalizedPos(), window);
|
||||
p.area = QHighDpi::toNativePixels(pt.screenRect(), window);
|
||||
QRectF area(QPointF(), pt.ellipseDiameters());
|
||||
area.moveCenter(pt.screenPos());
|
||||
p.area = QHighDpi::toNativePixels(area, window);
|
||||
p.pressure = pt.pressure();
|
||||
p.state = pt.state();
|
||||
p.velocity = QHighDpi::toNativePixels(pt.velocity(), window);
|
||||
|
@ -5920,10 +5920,6 @@ void QGraphicsScenePrivate::updateTouchPointsForItem(QGraphicsItem *item, QTouch
|
||||
item->d_ptr->genericMapFromSceneTransform(static_cast<const QWidget *>(touchEvent->target()));
|
||||
|
||||
for (auto &touchPoint : touchEvent->_touchPoints) {
|
||||
// Deprecated TouchPoint::setRect clobbers ellipseDiameters, restore
|
||||
const QSizeF ellipseDiameters = touchPoint.ellipseDiameters();
|
||||
touchPoint.setRect(mapFromScene.map(touchPoint.sceneRect()).boundingRect());
|
||||
touchPoint.setEllipseDiameters(ellipseDiameters);
|
||||
touchPoint.setPos(mapFromScene.map(touchPoint.scenePos()));
|
||||
touchPoint.setStartPos(mapFromScene.map(touchPoint.startScenePos()));
|
||||
touchPoint.setLastPos(mapFromScene.map(touchPoint.lastScenePos()));
|
||||
|
@ -4168,7 +4168,7 @@ bool QApplicationPrivate::updateTouchPointsForWidget(QWidget *widget, QTouchEven
|
||||
QTouchEvent::TouchPoint &touchPoint = touchEvent->_touchPoints[i];
|
||||
|
||||
// preserve the sub-pixel resolution
|
||||
const QPointF screenPos = touchPoint.screenRect().center();
|
||||
const QPointF screenPos = touchPoint.screenPos();
|
||||
const QPointF delta = screenPos - screenPos.toPoint();
|
||||
|
||||
touchPoint.d->pos = widget->mapFromGlobal(screenPos.toPoint()) + delta;
|
||||
|
Loading…
x
Reference in New Issue
Block a user