aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick
diff options
context:
space:
mode:
authorEike Hein <hein@kde.org>2016-01-21 00:01:12 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2016-09-15 14:19:08 +0000
commit4e6c5eade5504b335e31bd0950b9a702f8db58e7 (patch)
treea10a5a0dffc106fb186410373cda0168c1ae79df /src/quick
parent43a65845e6148a2346b2ccdb2442cef6c43df94c (diff)
Propagate window enter event as hover enter event in QQuickWindow
QQuickWindow currently propagates window leave events as hover leave events to its content item, but it does not propagate window enter events as corresponding hover enter events. Instead, hover enter is only triggered implicitly by mouse moves. This can cause problems when there is no mouse movement inbetween the window being entered and a subsequent button press event. A common example where this occurs is dismissing a mouse-grabbing popup window (e.g. a QMenu) by clicking outside the popup, and then clicking in the same spot that was clicked to dismiss the popup. Without this patch, hover state is not realized until movement occurs, so there may be no no visual feedback and code that needs to update state based on what is being hovered prior to handling a press event can't work correctly. This patch synthesizes a QHoverEvent and delivers it in response to QEvent::Enter, similar to how QEvent::Leave is already handled. QWidget handles this correctly via QWidget::enterEvent. The equivalent in Qt Quick is QQuickItem::hoverEnterEvent, ultimately called with the synthesized event. The patch also updates the touchmouse::hoverEnabled autotest. Due to the window enter event now being handled correctly, exitSpy2 would run up a count() of 2, as the cursor was not in a neutral position after previous test cases. The change makes sure the cursor is in a neutral position before test case activity. [ChangeLog][QQuickWindow] The relevant child item is now sent a hover event when the window receives a QEnterEvent, making sure hovering is recognized without waiting for mouse movement. Change-Id: If0586f6cd971df0dfc266bb1a39c9cdb184fd286 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quick')
-rw-r--r--src/quick/items/qquickwindow.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 8a2471b34f..26d83cfdf5 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -1437,6 +1437,15 @@ bool QQuickWindow::event(QEvent *e)
// return in order to avoid the QWindow::event below
return d->deliverTouchCancelEvent(static_cast<QTouchEvent*>(e));
break;
+ case QEvent::Enter: {
+ QEnterEvent *enter = static_cast<QEnterEvent*>(e);
+ bool accepted = enter->isAccepted();
+ bool delivered = d->deliverHoverEvent(d->contentItem, enter->windowPos(), d->lastMousePosition,
+ QGuiApplication::keyboardModifiers(), 0L, accepted);
+ enter->setAccepted(accepted);
+ return delivered;
+ }
+ break;
case QEvent::Leave:
d->clearHover();
d->lastMousePosition = QPoint();