From bf01a8d6f94dfb80bfa8ca382fefb929ec4ff998 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Thu, 9 Nov 2023 10:43:19 +0100 Subject: [PATCH] Cocoa plugin: make sure popups' collection behavior knows about spaces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ø (cherry picked from commit 360152bdcd0e4045b558e2bf598eabbf8a16abe8) Reviewed-by: Qt Cherry-pick Bot Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoawindow.mm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 8898da4ef96..25c315abad6 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1801,8 +1801,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;