From 122b4c21a023c08a352dd7d7463684805c1ad406 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 7 Dec 2023 17:54:27 +0100 Subject: [PATCH] macOS: Deliver focus change events for foreign windows If a foreign window becomes or loses focus window status, we should let QGuiApplication know about it. Task-number: QTBUG-119287 Change-Id: I550d72fa13e1c38c9b89880857db9f9cbd7f6568 Reviewed-by: Volker Hilsheimer (cherry picked from commit 75a5605151d203fb4c2269001dddfd3db121ea2e) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/platforms/cocoa/qcocoawindow.mm | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index e1714b104e9..14c72fd91a6 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1246,16 +1246,13 @@ void QCocoaWindow::windowDidEndLiveResize() void QCocoaWindow::windowDidBecomeKey() { - if (isForeignWindow()) - return; - // The NSWindow we're part of become key. Check if we're the first // responder, and if so, deliver focus window change to our window. if (m_view.window.firstResponder != m_view) return; qCDebug(lcQpaWindow) << m_view.window << "became key window." - << "Updating focus window to" << this; + << "Updating focus window to" << this << "with view" << m_view; if (windowIsPopupType()) { qCDebug(lcQpaWindow) << "Window is popup. Skipping focus window change."; @@ -1269,16 +1266,13 @@ void QCocoaWindow::windowDidBecomeKey() void QCocoaWindow::windowDidResignKey() { - if (isForeignWindow()) - return; - // The NSWindow we're part of lost key. Check if we're the first // responder, and if so, deliver window deactivation to our window. if (m_view.window.firstResponder != m_view) return; qCDebug(lcQpaWindow) << m_view.window << "resigned key window." - << "Clearing focus window" << this; + << "Clearing focus window" << this << "with view" << m_view; // Make sure popups are closed before we deliver activation changes, which are // otherwise ignored by QApplication.