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.6 6.5
Fixes: QTBUG-113507
Change-Id: Icbbc930fd1fc91089774340793e4bc452b939c1c
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
bb10
Timur Pocheptsov 2023-11-09 10:43:19 +01:00 committed by Tor Arne Vestbø
parent 8d367dec15
commit 360152bdcd
1 changed files with 3 additions and 2 deletions

View File

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