Emit CancelGrabExclusive when one grabber is replaced by another

Qt Quick Pointer Handlers depend on this behavior:
QQuickPointerHandler::onGrabChanged() receives only the grabber that
was losing the grab or the one that is receiving it, not both at the
same time.  UngrabExclusive means the original grabber simply
relinquished the grab by setting the exclusive grabber to null.
CancelGrabExclusive means the new grabber took over the grab that the
old grabber had before.

Task-number: QTBUG-86729
Change-Id: Iefca6fe91b11fcb03d2c6ac3598841c924facb22
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Shawn Rutledge 2020-09-18 18:17:21 +02:00
parent f1c1f44481
commit 1a3863147d

View File

@ -475,7 +475,8 @@ void QPointingDevicePrivate::setExclusiveGrabber(const QPointerEvent *event, con
auto oldGrabber = persistentPoint->exclusiveGrabber;
persistentPoint->exclusiveGrabber = exclusiveGrabber;
if (oldGrabber)
emit q->grabChanged(oldGrabber, QPointingDevice::UngrabExclusive, event, persistentPoint->eventPoint);
emit q->grabChanged(oldGrabber, exclusiveGrabber ? QPointingDevice::CancelGrabExclusive : QPointingDevice::UngrabExclusive,
event, persistentPoint->eventPoint);
if (Q_UNLIKELY(lcPointerGrab().isDebugEnabled())) {
qCDebug(lcPointerGrab) << name << "point" << point.id() << point.state()
<< "@" << point.scenePosition()