Cocoa plugin: make sure popups' collection behavior knows about spaces

It is possible to have several desktops on macOS, and even more - assign
an app to one particular desktop. Then, moving such an app to a different
desktop and using Qt's widgets like combobox may result in a strange
behavior: since it's not a native 'combo button', we create a popup
to show contents (list of items) of Qt's combobox and this popup
may open on a 'wrong' desktop (the one to which the app is assigned to).
To address this, combine the existing collection behavior for popups
with NSWindowCollectionBehaviorMoveToActiveSpace.

Pick-to: 6.5
Fixes: QTBUG-113507
Change-Id: Icbbc930fd1fc91089774340793e4bc452b939c1c
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 360152bdcd0e4045b558e2bf598eabbf8a16abe8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
Timur Pocheptsov 2023-11-09 10:43:19 +01:00 committed by Qt Cherry-pick Bot
parent 8cde7151ad
commit bf01a8d6f9

View File

@ -1801,8 +1801,9 @@ QCocoaNSWindow *QCocoaWindow::createNSWindow(bool shouldBePanel)
// Qt::Tool windows hide on app deactivation, unless Qt::WA_MacAlwaysShowToolWindow is set // Qt::Tool windows hide on app deactivation, unless Qt::WA_MacAlwaysShowToolWindow is set
nsWindow.hidesOnDeactivate = ((type & Qt::Tool) == Qt::Tool) && !alwaysShowToolWindow(); nsWindow.hidesOnDeactivate = ((type & Qt::Tool) == Qt::Tool) && !alwaysShowToolWindow();
// Make popup windows show on the same desktop as the parent full-screen window // Make popup windows show on the same desktop as the parent window
nsWindow.collectionBehavior = NSWindowCollectionBehaviorFullScreenAuxiliary; nsWindow.collectionBehavior = NSWindowCollectionBehaviorFullScreenAuxiliary
| NSWindowCollectionBehaviorMoveToActiveSpace;
if ((type & Qt::Popup) == Qt::Popup) { if ((type & Qt::Popup) == Qt::Popup) {
nsWindow.hasShadow = YES; nsWindow.hasShadow = YES;