aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/quick/items/qquickevents.cpp2
-rw-r--r--src/quick/items/qquickevents_p_p.h4
-rw-r--r--src/quick/items/qquickwindow.cpp22
-rw-r--r--src/quick/items/qquickwindow_p.h1
4 files changed, 15 insertions, 14 deletions
diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp
index 80a4e6bd9a..96eb59f518 100644
--- a/src/quick/items/qquickevents.cpp
+++ b/src/quick/items/qquickevents.cpp
@@ -574,7 +574,7 @@ QQuickEventPoint *QQuickPointerTouchEvent::point(int i) const {
}
QQuickEventPoint::QQuickEventPoint(QQuickPointerEvent *parent)
- : QObject(parent), m_pointId(0), m_timestamp(0), m_pressTimestamp(0),
+ : QObject(parent), m_pointId(0), m_grabber(nullptr), m_timestamp(0), m_pressTimestamp(0),
m_state(Qt::TouchPointReleased), m_valid(false), m_accept(false)
{
Q_UNUSED(m_reserved);
diff --git a/src/quick/items/qquickevents_p_p.h b/src/quick/items/qquickevents_p_p.h
index f2e06b69df..3cec7c782a 100644
--- a/src/quick/items/qquickevents_p_p.h
+++ b/src/quick/items/qquickevents_p_p.h
@@ -253,6 +253,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickEventPoint : public QObject
Q_PROPERTY(quint64 pointId READ pointId)
Q_PROPERTY(qreal timeHeld READ timeHeld)
Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
+ Q_PROPERTY(QQuickItem *grabber READ grabber WRITE setGrabber)
public:
QQuickEventPoint(QQuickPointerEvent *parent);
@@ -280,10 +281,13 @@ public:
qreal timeHeld() const { return (m_timestamp - m_pressTimestamp) / 1000.0; }
bool isAccepted() const { return m_accept; }
void setAccepted(bool accepted = true) { m_accept = accepted; }
+ QQuickItem *grabber() const { return m_grabber; }
+ void setGrabber(QQuickItem *grabber) { m_grabber = grabber; }
private:
QPointF m_scenePos;
quint64 m_pointId;
+ QQuickItem *m_grabber;
ulong m_timestamp;
ulong m_pressTimestamp;
Qt::TouchPointState m_state;
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 7a524a1377..a8565be414 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -471,7 +471,6 @@ void QQuickWindowPrivate::renderSceneGraph(const QSize &size)
QQuickWindowPrivate::QQuickWindowPrivate()
: contentItem(0)
, activeFocusItem(0)
- , mouseGrabberItem(0)
#ifndef QT_NO_CURSOR
, cursorItem(0)
#endif
@@ -751,7 +750,10 @@ void QQuickWindowPrivate::setMouseGrabber(QQuickItem *grabber)
qCDebug(DBG_MOUSE_TARGET) << "grabber" << q->mouseGrabberItem() << "->" << grabber;
QQuickItem *oldGrabber = q->mouseGrabberItem();
- mouseGrabberItem = grabber;
+
+ QQuickPointerEvent *event = QQuickPointerDevice::genericMouseDevice()->pointerEvent();
+ Q_ASSERT(event->pointCount() == 1);
+ event->point(0)->setGrabber(grabber);
if (grabber && touchMouseId != -1) {
// update the touch item for mouse touch id to the new grabber
@@ -778,12 +780,10 @@ void QQuickWindowPrivate::grabTouchPoints(QQuickItem *grabber, const QVector<int
if (oldGrabber)
ungrab.insert(oldGrabber);
- QQuickItem *originalMouseGrabberItem = mouseGrabberItem;
+ QQuickItem *mouseGrabberItem = q->mouseGrabberItem();
if (touchMouseId == ids.at(i) && mouseGrabberItem && mouseGrabberItem != grabber) {
qCDebug(DBG_MOUSE_TARGET) << "grabTouchPoints: grabber" << mouseGrabberItem << "-> null";
- mouseGrabberItem = 0;
- QEvent ev(QEvent::UngrabMouse);
- q->sendEvent(originalMouseGrabberItem, &ev);
+ setMouseGrabber(nullptr);
}
}
foreach (QQuickItem *oldGrabber, ungrab)
@@ -804,9 +804,7 @@ void QQuickWindowPrivate::removeGrabber(QQuickItem *grabber, bool mouse, bool to
}
if (Q_LIKELY(mouse) && q->mouseGrabberItem() == grabber) {
qCDebug(DBG_MOUSE_TARGET) << "removeGrabber" << q->mouseGrabberItem() << "-> null";
- mouseGrabberItem = 0;
- QEvent ev(QEvent::UngrabMouse);
- q->sendEvent(grabber, &ev);
+ setMouseGrabber(nullptr);
}
}
@@ -1481,9 +1479,9 @@ QObject *QQuickWindow::focusObject() const
*/
QQuickItem *QQuickWindow::mouseGrabberItem() const
{
- Q_D(const QQuickWindow);
-
- return d->mouseGrabberItem;
+ QQuickPointerEvent *event = QQuickPointerDevice::genericMouseDevice()->pointerEvent();
+ Q_ASSERT(event->pointCount());
+ return event->point(0)->grabber();
}
diff --git a/src/quick/items/qquickwindow_p.h b/src/quick/items/qquickwindow_p.h
index 15ac701c54..0579295fca 100644
--- a/src/quick/items/qquickwindow_p.h
+++ b/src/quick/items/qquickwindow_p.h
@@ -125,7 +125,6 @@ public:
void deliverKeyEvent(QKeyEvent *e);
// Keeps track of the item currently receiving mouse events
- QQuickItem *mouseGrabberItem;
#ifndef QT_NO_CURSOR
QQuickItem *cursorItem;
#endif