Details
-
Technical task
-
Resolution: Done
-
Not Evaluated
-
None
-
-
65c9acc5f529689f609ebec5e6aae59a171982e4 (qt/qtbase/dev)
Description
macOS is the only platform that actively redirects mouse and keyboard input to the active popup. To do so, the Cocoa QPA plugin maintains a stack of popup windows in
QCocoaIntegration.
To achieve consistent interpretation of Qt::Popup across platforms, we should move the logic of implicitly grabbing mouse and keyboard input to the event dispatching in QGuiApplication or QWindow, and perhaps move the entire popup stack data structure there as well.
This would allow us to remove this code from the Qt Cocoa implementation, which right now takes care of the following:
Block the CMD+H application shortcut from hiding the window if a Qt::Popup window is currently active
Except when the popup is a tooltip, as per QTBUG-82626
Native applications allow CMD+H to hide the application even when a context menu is open, e.g. Safari or Xcode. So this code can just go away, once the stack is removed so that it doesn't get out of sync (esp once key and mouse event redirection is gone).
Redirect key and mouse events to the active popup (unless it's a tooltip)
This is not done on other platforms, see QTBUG-96449 - this code should just be removed.
Close all popups when the user clicks the frame of the window
Something needs to be done, as clicks into the non-client area on macOS don't generate mouse events that Qt can see, so the usual closing of popup type QWidgets won't kick in. See QTBUG-30522. Related also QTBUG-77833, the fix of which introduced another implementation that closes all popups in the cocoa stack when the user clicks on the minimize jewel; that case is fixed by QTBUG-30522 as well, so that code is never run anymore.
Windows and X11 don't close QWindow popups when clicking into the frame of the window either; but since a popup QWidget gets the event, this is ok.
Perhaps this can be done via a virtual QGuiApplicationPrivate helper that is overridden in QApplicationPrivate to use the popup stack already managed there (QApplicationPrivate::popupWidgets).
Implement closing of popups when a mouse event is blocked by a modal session
A mouse event outside of the active popup AND into a window that is currently blocked by a modal session is blocked by macOS; only our NSWindow::sendEvent implementation sees it, no QMouseEvent is generated. For such blocked events while a popup is open need to be passed on to our handleMouseEvent code explicitly, for which we need to know that we are in popup mode. See https://codereview.qt-project.org/c/qt/qtbase/+/369794, we can probably just call QGuiApplicationPrivate::popupActive here.
Attachments
Issue Links
- relates to
-
QTBUG-68080 we need to move popup event forwarding logic from QWidgetWindow::handleMouseEvent() to QGuiApplication
- Closed