From 1a3863147d8b7680076c5268900d76f7503f1fb4 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 18 Sep 2020 18:17:21 +0200 Subject: [PATCH] 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 --- src/gui/kernel/qpointingdevice.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qpointingdevice.cpp b/src/gui/kernel/qpointingdevice.cpp index 779893861a..349fb55cbe 100644 --- a/src/gui/kernel/qpointingdevice.cpp +++ b/src/gui/kernel/qpointingdevice.cpp @@ -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()