From fd70c80fe1cac83776cc4730555c8e3dea930c1c Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 30 Nov 2015 16:39:15 +0100 Subject: Fix containsMouse with touch and hoverEnabled When we synthesize a press/release from touch, the item believes that the mouse never leaves, so if we have several mouse areas, they may all claim that they contain the mouse at the same time. The solution is to synthesize a move back to the actual mouse position. Task-number: QTBUG-40856 Change-Id: I43610d95aa383f847db18b387405b0c4e91cea0f Reviewed-by: Shawn Rutledge --- src/quick/items/qquickwindow.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 845fa816c9..e12b22bb00 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -631,6 +631,15 @@ bool QQuickWindowPrivate::translateTouchToMouse(QQuickItem *item, QTouchEvent *e if (mouseGrabberItem) { QScopedPointer me(touchToMouseEvent(QEvent::MouseButtonRelease, p, event, mouseGrabberItem, false)); QCoreApplication::sendEvent(item, me.data()); + + if (item->acceptHoverEvents() && p.screenPos() != QGuiApplicationPrivate::lastCursorPosition) { + QPointF localMousePos(qInf(), qInf()); + if (QWindow *w = item->window()) + localMousePos = item->mapFromScene(w->mapFromGlobal(QGuiApplicationPrivate::lastCursorPosition.toPoint())); + QMouseEvent mm(QEvent::MouseMove, localMousePos, QGuiApplicationPrivate::lastCursorPosition, + Qt::NoButton, Qt::NoButton, event->modifiers()); + QCoreApplication::sendEvent(item, &mm); + } if (mouseGrabberItem) // might have ungrabbed due to event mouseGrabberItem->ungrabMouse(); return me->isAccepted(); -- cgit v1.2.3