From 65c9acc5f529689f609ebec5e6aae59a171982e4 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 15 Sep 2021 14:38:22 +0200 Subject: macOS: remove the popup stack from QCocoaIntegration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since popup handling is now done exclusively by Q(Gui)Application, we don't need to keep track of the popup stack in the Cocoa plugin anymore. Fixes: QTBUG-96450 Change-Id: I869f36f52bc2210b6c92efd9425502de4122c553 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoaintegration.h | 6 ----- src/plugins/platforms/cocoa/qcocoaintegration.mm | 24 ------------------ src/plugins/platforms/cocoa/qcocoawindow.mm | 16 ++---------- src/plugins/platforms/cocoa/qnsview.h | 1 - src/plugins/platforms/cocoa/qnsview_mouse.mm | 32 ------------------------ 5 files changed, 2 insertions(+), 77 deletions(-) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h index ffd1bc5b6e..fc9580b1b8 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.h +++ b/src/plugins/platforms/cocoa/qcocoaintegration.h @@ -124,11 +124,6 @@ public: NSToolbar *toolbar(QWindow *window) const; void clearToolbars(); - void pushPopupWindow(QCocoaWindow *window); - QCocoaWindow *popPopupWindow(); - QCocoaWindow *activePopupWindow() const; - QList *popupWindowStack(); - void setApplicationIcon(const QIcon &icon) const override; void beep() const override; @@ -160,7 +155,6 @@ private: mutable QCocoaVulkanInstance *mCocoaVulkanInstance = nullptr; #endif QHash mToolbars; - QList m_popupWindowStack; }; Q_DECLARE_OPERATORS_FOR_FLAGS(QCocoaIntegration::Options) diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index e936a7c121..b5d9d48a8a 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -454,30 +454,6 @@ void QCocoaIntegration::clearToolbars() mToolbars.clear(); } -void QCocoaIntegration::pushPopupWindow(QCocoaWindow *window) -{ - m_popupWindowStack.append(window); -} - -QCocoaWindow *QCocoaIntegration::popPopupWindow() -{ - if (m_popupWindowStack.isEmpty()) - return nullptr; - return m_popupWindowStack.takeLast(); -} - -QCocoaWindow *QCocoaIntegration::activePopupWindow() const -{ - if (m_popupWindowStack.isEmpty()) - return nullptr; - return m_popupWindowStack.front(); -} - -QList *QCocoaIntegration::popupWindowStack() -{ - return &m_popupWindowStack; -} - void QCocoaIntegration::setApplicationIcon(const QIcon &icon) const { // Fall back to a size that looks good on the highest resolution screen available diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 6a826b4d66..5ffc36a895 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -204,17 +204,13 @@ QCocoaWindow::~QCocoaWindow() if (!isForeignWindow()) [[NSNotificationCenter defaultCenter] removeObserver:m_view]; - if (QCocoaIntegration *cocoaIntegration = QCocoaIntegration::instance()) { - // While it is unlikely that this window will be in the popup stack - // during deletetion we clear any pointers here to make sure. - cocoaIntegration->popupWindowStack()->removeAll(this); - #if QT_CONFIG(vulkan) + if (QCocoaIntegration *cocoaIntegration = QCocoaIntegration::instance()) { auto vulcanInstance = cocoaIntegration->getCocoaVulkanInstance(); if (vulcanInstance) vulcanInstance->destroySurface(m_vulkanSurface); -#endif } +#endif [m_view release]; [m_nsWindow close]; @@ -336,11 +332,6 @@ void QCocoaWindow::setVisible(bool visible) // so we can send the geometry change. FIXME: Get rid of this workaround. handleGeometryChange(); - // Register popup windows. The Cocoa platform plugin will forward mouse events - // to them and close them when needed. - if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip) - QCocoaIntegration::instance()->pushPopupWindow(this); - if (parentCocoaWindow) { // The parent window might have moved while this window was hidden, // update the window geometry if there is a parent. @@ -449,9 +440,6 @@ void QCocoaWindow::setVisible(bool visible) removeMonitor(); - if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip) - QCocoaIntegration::instance()->popupWindowStack()->removeAll(this); - if (parentCocoaWindow && window()->type() == Qt::Popup) { NSWindow *nativeParentWindow = parentCocoaWindow->nativeWindow(); if (m_resizableTransientParent diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index f4be8c466f..526e4c0be2 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -58,7 +58,6 @@ QT_DECLARE_NAMESPACED_OBJC_INTERFACE(QNSView, NSView @interface QNSView (MouseAPI) - (void)handleMouseEvent:(NSEvent *)theEvent; - (void)handleFrameStrutMouseEvent:(NSEvent *)theEvent; -- (bool)closePopups:(NSEvent *)theEvent; - (void)resetMouseButtons; @end diff --git a/src/plugins/platforms/cocoa/qnsview_mouse.mm b/src/plugins/platforms/cocoa/qnsview_mouse.mm index d6492f858a..f7081503b7 100644 --- a/src/plugins/platforms/cocoa/qnsview_mouse.mm +++ b/src/plugins/platforms/cocoa/qnsview_mouse.mm @@ -259,38 +259,6 @@ static const QPointingDevice *pointingDeviceFor(qint64 deviceID) QWindowSystemInterface::handleFrameStrutMouseEvent(m_platformWindow->window(), timestamp, qtWindowPoint, qtScreenPoint, m_frameStrutButtons, button, eventType); } - -- (bool)closePopups:(NSEvent *)theEvent -{ - QList *popups = QCocoaIntegration::instance()->popupWindowStack(); - if (!popups->isEmpty()) { - // Check if the click is outside all popups. - bool inside = false; - QPointF qtScreenPoint = QCocoaScreen::mapFromNative([self screenMousePoint:theEvent]); - for (QList::const_iterator it = popups->begin(); it != popups->end(); ++it) { - if ((*it)->geometry().contains(qtScreenPoint.toPoint())) { - inside = true; - break; - } - } - // Close the popups if the click was outside. - if (!inside) { - bool selfClosed = false; - Qt::WindowType type = QCocoaIntegration::instance()->activePopupWindow()->window()->type(); - while (QCocoaWindow *popup = QCocoaIntegration::instance()->popPopupWindow()) { - selfClosed = self == popup->view(); - QWindowSystemInterface::handleCloseEvent(popup->window()); - if (!m_platformWindow) - return true; // Bail out if window was destroyed - } - // Consume the mouse event when closing the popup, except for tool tips - // were it's expected that the event is processed normally. - if (type != Qt::ToolTip || selfClosed) - return true; - } - } - return false; -} @end @implementation QNSView (Mouse) -- cgit v1.2.3