summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2021-09-18 15:46:51 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2021-09-24 21:37:06 +0200
commita03a67fbfaba28d87cccab6a7fe09ebd5da71d16 (patch)
tree6e32d21623ae0f9730af81deb22ca789c94d3424
parent0be5bf3e64cee329249c1174590d6a0c1a7a543f (diff)
macOS: Remove special cases in enter/leave event handling
The Cocoa QPA plugin no longer tracks popups, but dispatches enter/leave events when popups show and hide. So the special handling in tests and QWidgetWindow can go away now. Change-Id: Ib6ef00689de231996e5e57ecdd8fd0d4c861d68b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp6
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp4
2 files changed, 2 insertions, 8 deletions
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index 0d73e55719..69c76112f6 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -392,14 +392,13 @@ QPointer<QWidget> qt_last_mouse_receiver = nullptr;
void QWidgetWindow::handleEnterLeaveEvent(QEvent *event)
{
-#if !defined(Q_OS_MACOS) && !defined(Q_OS_IOS) // Cocoa tracks popups
// Ignore all enter/leave events from QPA if we are not on the first-level context menu.
// This prevents duplicated events on most platforms. Fake events will be delivered in
// QWidgetWindow::handleMouseEvent(QMouseEvent *). Make an exception whether the widget
// is already under mouse - let the mouse leave.
if (QApplicationPrivate::inPopupMode() && m_widget != QApplication::activePopupWidget() && !m_widget->underMouse())
return;
-#endif
+
if (event->type() == QEvent::Leave) {
QWidget *enter = nullptr;
// Check from window system event queue if the next queued enter targets a window
@@ -540,7 +539,6 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
if (receiver != activePopupWidget)
widgetPos = receiver->mapFromGlobal(event->globalPosition().toPoint());
-#if !defined(Q_OS_MACOS) && !defined(Q_OS_IOS) // Cocoa tracks popups
const bool reallyUnderMouse = activePopupWidget->rect().contains(mapped);
const bool underMouse = activePopupWidget->underMouse();
if (underMouse != reallyUnderMouse) {
@@ -558,7 +556,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
receiver = activePopupWidget;
}
}
-#endif
+
if ((event->type() != QEvent::MouseButtonPress) || !(QMutableSinglePointEvent::from(event)->isDoubleClick())) {
// if the widget that was pressed is gone, then deliver move events without buttons
const auto buttons = event->type() == QEvent::MouseMove && qt_popup_down_closed
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 5cd88f9ab8..2d77e4af93 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -11506,10 +11506,6 @@ void tst_QWidget::underMouse()
// Mouse leaves popup and enters topLevelWidget, should cause leave for popup
// but no enter to topLevelWidget.
-#ifdef Q_OS_DARWIN
- // Artificial leave event needed for Cocoa.
- QWindowSystemInterface::handleLeaveEvent(popupWindow);
-#endif
QTest::mouseMove(popupWindow, popupWindow->mapFromGlobal(window->mapToGlobal(inWindowPoint)));
QApplication::processEvents();
QVERIFY(!topLevelWidget.underMouse());