From ae3594436b9b0540ef94379a73bf8fec8d3b7465 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 7 Dec 2020 16:48:31 +0100 Subject: macOS: Always allow interacting with popup windows during modal session f4889e63c7b changed the worksWhenModal logic for QNSWindow to be based on the transient parent relationship of the child window to the modal session window, to fix many issues where windows that should be blocked were not. Unfortunately, some window types do not maintain a transient parent relationship (e.g. QCompleter, which is itself just a QObject), or are not common for users to create with a QWidget parent (such as a context QMenu). This change restores part of the special-casing that was removed in f4889e, so that all popup windows are always allowed to be interacted with during modal sessions. This includes popup windows that were opened as part of a parent modal session, which would normally be fully blocked, but we assume that popup windows are intermittent enough that this will not be a problem. For now we leave out the other two special casings from f4889e, namely tool windows and dialogs. The former should in most cases be created with a parent window, while the latter definitely should. Fixes: QTBUG-88188 Fixes: QTBUG-88985 Fixes: QTBUG-87849 Fixes: QTBUG-86845 Pick-to: 6.0 Pick-to: 5.15 Change-Id: I005a402b21e8dc16c3b18bcd7e67d12b94a66f44 Reviewed-by: Volker Hilsheimer --- src/plugins/platforms/cocoa/qnswindow.mm | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qnswindow.mm b/src/plugins/platforms/cocoa/qnswindow.mm index e7c7f6dc5d..d9158bbcae 100644 --- a/src/plugins/platforms/cocoa/qnswindow.mm +++ b/src/plugins/platforms/cocoa/qnswindow.mm @@ -180,6 +180,14 @@ static bool isMouseEvent(NSEvent *ev) if (!NSApp.modalWindow) return NO; + // Special case popup windows (menus, completions, etc), as these usually + // don't have a transient parent set, and we don't want to block them. The + // assumption is that these windows are only opened intermittently, from + // within windows that can already be interacted with in this modal session. + Qt::WindowType type = m_platformWindow->window()->type(); + if (type == Qt::Popup) + return YES; + // If the current modal window (top level modal session) is not a Qt window we // have no way of knowing if this window is transient child of the modal window. if (![NSApp.modalWindow conformsToProtocol:@protocol(QNSWindowProtocol)]) -- cgit v1.2.3