aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickwindow.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2018-01-09 14:32:32 +0100
committerLiang Qi <liang.qi@qt.io>2018-01-09 14:32:32 +0100
commite3f7da72ac5b4540f88bb5cbd91a4917ba84334a (patch)
tree3f05c1cf965fe291685c383f04b0bec87b05095b /src/quick/items/qquickwindow.cpp
parent4cc883452b37dbe3148064150dc2f6b282b6b816 (diff)
parent2e8a45d99f94cbd2c805dd3de56d60d9baa9bd4e (diff)
Merge remote-tracking branch 'origin/5.10' into dev
Conflicts: .qmake.conf src/qml/memory/qv4mm.cpp src/qml/qml/qqmlbinding.cpp Change-Id: I98e51ef5af12691196da5772a07d3d53d213efcc
Diffstat (limited to 'src/quick/items/qquickwindow.cpp')
-rw-r--r--src/quick/items/qquickwindow.cpp65
1 files changed, 23 insertions, 42 deletions
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 436adf8c49..cfeaa6f22d 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -747,44 +747,6 @@ bool QQuickWindowPrivate::deliverTouchAsMouse(QQuickItem *item, QQuickPointerEve
return false;
}
-void QQuickWindowPrivate::setMouseGrabber(QQuickItem *grabber)
-{
- Q_Q(QQuickWindow);
- if (q->mouseGrabberItem() == grabber)
- return;
-
- QQuickItem *oldGrabber = q->mouseGrabberItem();
- qCDebug(DBG_MOUSE_TARGET) << "grabber" << oldGrabber << "->" << grabber;
-
- if (grabber && touchMouseId != -1 && touchMouseDevice) {
- // update the touch item for mouse touch id to the new grabber
- qCDebug(DBG_TOUCH_TARGET) << "TP (mouse)" << hex << touchMouseId << "->" << q->mouseGrabberItem();
- auto point = pointerEventInstance(touchMouseDevice)->pointById(touchMouseId);
- if (point) {
- auto originalEvent = pointerEventInstance(point->pointerEvent()->device());
- for (int i = 0; i < originalEvent->pointCount(); ++i) {
- QQuickEventPoint *pt = originalEvent->point(i);
- if (pt->exclusiveGrabber())
- pt->cancelExclusiveGrab();
- }
- point->setGrabberItem(grabber);
- }
- } else {
- QQuickPointerEvent *event = pointerEventInstance(QQuickPointerDevice::genericMouseDevice());
- Q_ASSERT(event->pointCount() == 1);
- auto point = event->point(0);
- point->setGrabberItem(grabber);
- }
-
-
- if (oldGrabber) {
- QEvent e(QEvent::UngrabMouse);
- hasFiltered.clear();
- if (!sendFilteredMouseEvent(&e, oldGrabber, oldGrabber->parentItem()))
- oldGrabber->mouseUngrabEvent();
- }
-}
-
void QQuickWindowPrivate::grabTouchPoints(QObject *grabber, const QVector<int> &ids)
{
for (int i = 0; i < ids.count(); ++i) {
@@ -832,8 +794,14 @@ void QQuickWindowPrivate::removeGrabber(QQuickItem *grabber, bool mouse, bool to
{
Q_Q(QQuickWindow);
if (Q_LIKELY(mouse) && q->mouseGrabberItem() == grabber) {
- qCDebug(DBG_MOUSE_TARGET) << "removeGrabber" << q->mouseGrabberItem() << "-> null";
- setMouseGrabber(nullptr);
+ bool fromTouch = isDeliveringTouchAsMouse();
+ auto point = fromTouch ?
+ pointerEventInstance(touchMouseDevice)->pointById(touchMouseId) :
+ pointerEventInstance(QQuickPointerDevice::genericMouseDevice())->point(0);
+ QQuickItem *oldGrabber = point->grabberItem();
+ qCDebug(DBG_MOUSE_TARGET) << "removeGrabber" << oldGrabber << "-> null";
+ point->setGrabberItem(nullptr);
+ sendUngrabEvent(oldGrabber, fromTouch);
}
if (Q_LIKELY(touch)) {
bool ungrab = false;
@@ -853,6 +821,19 @@ void QQuickWindowPrivate::removeGrabber(QQuickItem *grabber, bool mouse, bool to
}
}
+void QQuickWindowPrivate::sendUngrabEvent(QQuickItem *grabber, bool touch)
+{
+ if (!grabber)
+ return;
+ QEvent e(QEvent::UngrabMouse);
+ hasFiltered.clear();
+ if (!sendFilteredMouseEvent(&e, grabber, grabber->parentItem())) {
+ grabber->mouseUngrabEvent();
+ if (touch)
+ grabber->touchUngrabEvent();
+ }
+}
+
/*!
Translates the data in \a touchEvent to this window. This method leaves the item local positions in
\a touchEvent untouched (these are filled in later).
@@ -1519,7 +1500,7 @@ QQuickItem *QQuickWindow::mouseGrabberItem() const
{
Q_D(const QQuickWindow);
- if (d->touchMouseId != -1 && d->touchMouseDevice) {
+ if (d->isDeliveringTouchAsMouse()) {
if (QQuickPointerEvent *event = d->queryPointerEventInstance(d->touchMouseDevice)) {
auto point = event->pointById(d->touchMouseId);
return point ? point->grabberItem() : nullptr;
@@ -1744,7 +1725,7 @@ void QQuickWindowPrivate::deliverMouseEvent(QQuickPointerMouseEvent *pointerEven
// release event: ungrab if no buttons are pressed anymore
if (mouseIsReleased)
- setMouseGrabber(nullptr);
+ removeGrabber(grabber, true, isDeliveringTouchAsMouse());
} else {
// if the grabber is not an Item, it must be a PointerHandler
auto handler = point->grabberPointerHandler();