aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/quick/items/qquickflickable.cpp5
-rw-r--r--src/quick/items/qquickitem.cpp10
-rw-r--r--src/quick/items/qquickwindow.cpp34
-rw-r--r--src/quick/items/qquickwindow_p.h1
4 files changed, 36 insertions, 14 deletions
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp
index 15627aad84..fa18d4aa30 100644
--- a/src/quick/items/qquickflickable.cpp
+++ b/src/quick/items/qquickflickable.cpp
@@ -2048,12 +2048,13 @@ bool QQuickFlickable::sendMouseEvent(QQuickItem *item, QMouseEvent *event)
if ((grabber && stealThisEvent && !grabber->keepMouseGrab() && grabber != this) || grabberDisabled) {
d->clearDelayedPress();
grabMouse();
+ } else if (d->delayedPressEvent) {
+ grabMouse();
}
- // Do not accept this event when filtering, as this would force the mouse grab to the child
const bool filtered = stealThisEvent || d->delayedPressEvent || grabberDisabled;
if (filtered) {
- event->setAccepted(false);
+ event->setAccepted(true);
}
return filtered;
} else if (d->lastPosTime != -1) {
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index a0329f7afc..f565fba1bb 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -6629,15 +6629,7 @@ void QQuickItem::grabMouse()
if (!d->window)
return;
QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(d->window);
- if (windowPriv->mouseGrabberItem == this)
- return;
-
- QQuickItem *oldGrabber = windowPriv->mouseGrabberItem;
- windowPriv->mouseGrabberItem = this;
- if (oldGrabber) {
- QEvent ev(QEvent::UngrabMouse);
- d->window->sendEvent(oldGrabber, &ev);
- }
+ windowPriv->setMouseGrabber(this);
}
/*!
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index dfc70d7e68..f355afcea5 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -599,6 +599,28 @@ bool QQuickWindowPrivate::translateTouchToMouse(QQuickItem *item, QTouchEvent *e
return false;
}
+void QQuickWindowPrivate::setMouseGrabber(QQuickItem *grabber)
+{
+ Q_Q(QQuickWindow);
+ if (mouseGrabberItem == grabber)
+ return;
+
+ QQuickItem *oldGrabber = mouseGrabberItem;
+ mouseGrabberItem = grabber;
+
+ if (touchMouseId != -1) {
+ // update the touch item for mouse touch id to the new grabber
+ itemForTouchPointId.remove(touchMouseId);
+ if (grabber)
+ itemForTouchPointId[touchMouseId] = grabber;
+ }
+
+ if (oldGrabber) {
+ QEvent ev(QEvent::UngrabMouse);
+ q->sendEvent(oldGrabber, &ev);
+ }
+}
+
void QQuickWindowPrivate::transformTouchPoints(QList<QTouchEvent::TouchPoint> &touchPoints, const QTransform &transform)
{
QMatrix4x4 transformMatrix(transform);
@@ -1221,8 +1243,11 @@ bool QQuickWindow::event(QEvent *e)
case QEvent::TouchEnd: {
QTouchEvent *touch = static_cast<QTouchEvent*>(e);
d->translateTouchEvent(touch);
- // return in order to avoid the QWindow::event below
- return d->deliverTouchEvent(touch);
+ d->deliverTouchEvent(touch);
+ // we consume all touch events ourselves to avoid duplicate
+ // mouse delivery by QtGui mouse synthesis
+ e->accept();
+ return true;
}
break;
case QEvent::TouchCancel:
@@ -1776,7 +1801,10 @@ bool QQuickWindowPrivate::deliverMatchingPointsToItem(QQuickItem *item, QTouchEv
// First check whether the parent wants to be a filter,
// and if the parent accepts the event we are done.
if (sendFilteredTouchEvent(item->parentItem(), item, event)) {
- event->accept();
+ // If the touch was accepted (regardless by whom or in what form),
+ // update acceptedNewPoints
+ foreach (int id, matchingNewPoints)
+ acceptedNewPoints->insert(id);
return true;
}
diff --git a/src/quick/items/qquickwindow_p.h b/src/quick/items/qquickwindow_p.h
index c23745b5f1..418633b6ac 100644
--- a/src/quick/items/qquickwindow_p.h
+++ b/src/quick/items/qquickwindow_p.h
@@ -127,6 +127,7 @@ public:
QPointF lastMousePosition;
bool translateTouchToMouse(QQuickItem *item, QTouchEvent *event);
void translateTouchEvent(QTouchEvent *touchEvent);
+ void setMouseGrabber(QQuickItem *grabber);
static void transformTouchPoints(QList<QTouchEvent::TouchPoint> &touchPoints, const QTransform &transform);
static QMouseEvent *cloneMouseEvent(QMouseEvent *event, QPointF *transformedLocalPos = 0);
bool deliverInitialMousePressEvent(QQuickItem *, QMouseEvent *);