summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2018-05-07 14:56:26 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2018-05-15 13:19:40 +0000
commit710f9507c0ebf01d9e9f717e676b9c3b1b94ee8a (patch)
tree8d50c384e6d18b92612cacdaafd211de004a47a6
parentbe4c4877b35ad1b6983cf194e61f0dad1d123af5 (diff)
setGrabberItem: consistently call touchUngrabEvent or mouseUngrabEvent
Calling grabberItem() to get the old grabber must come before setting m_exclusiveGrabber. Then we call oldGrabberItem->touchUngrabEvent() or oldGrabberItem->mouseUngrabEvent() as appropriate. Now the responsibility for this is moved from QQuickItem::grabMouse() to QQuickEventPoint::setGrabberItem() (which it calls). Task-number: QTBUG-65648 Change-Id: Ia6219cb798d7f671ccc4006d51eeb87dbdbda3ef Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
-rw-r--r--src/quick/items/qquickevents.cpp10
-rw-r--r--src/quick/items/qquickitem.cpp5
2 files changed, 7 insertions, 8 deletions
diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp
index d964f2bb32..d020ad7c4c 100644
--- a/src/quick/items/qquickevents.cpp
+++ b/src/quick/items/qquickevents.cpp
@@ -849,14 +849,16 @@ void QQuickEventPoint::setGrabberItem(QQuickItem *grabber)
qCDebug(lcPointerGrab) << pointDeviceName(this) << "point" << hex << m_pointId << pointStateString(this)
<< ": grab" << m_exclusiveGrabber << "->" << grabber;
}
+ QQuickItem *oldGrabberItem = grabberItem();
m_exclusiveGrabber = QPointer<QObject>(grabber);
m_grabberIsHandler = false;
m_sceneGrabPos = m_scenePos;
- QQuickItem *oldGrabberItem = grabberItem();
- if (oldGrabberHandler)
+ if (oldGrabberHandler) {
oldGrabberHandler->onGrabChanged(oldGrabberHandler, (grabber ? CancelGrabExclusive : UngrabExclusive), this);
- else if (oldGrabberItem && oldGrabberItem != grabber && grabber && pointerEvent()->asPointerTouchEvent())
- oldGrabberItem->touchUngrabEvent();
+ } else if (oldGrabberItem && oldGrabberItem != grabber && grabber && grabber->window()) {
+ QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(grabber->window());
+ windowPriv->sendUngrabEvent(oldGrabberItem, windowPriv->isDeliveringTouchAsMouse());
+ }
for (QPointer<QQuickPointerHandler> passiveGrabber : m_passiveGrabbers)
passiveGrabber->onGrabChanged(passiveGrabber, OverrideGrabPassive, this);
}
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index 3d650bf223..70bb7db2b0 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -7462,11 +7462,8 @@ void QQuickItem::grabMouse()
auto point = fromTouch ?
windowPriv->pointerEventInstance(windowPriv->touchMouseDevice)->pointById(windowPriv->touchMouseId) :
windowPriv->pointerEventInstance(QQuickPointerDevice::genericMouseDevice())->point(0);
- if (point) {
- QQuickItem *oldGrabber = point->grabberItem();
+ if (point)
point->setGrabberItem(this);
- windowPriv->sendUngrabEvent(oldGrabber, fromTouch);
- }
}
/*!