diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index e0fc678656..c94b8a5df3 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -154,8 +154,15 @@ static QTouchDevice *touchDevice = 0; if (!m_platformWindow->windowIsPopupType()) QWindowSystemInterface::handleWindowActivated(m_window); } else if (notificationName == NSWindowDidResignKeyNotification) { - if (!m_platformWindow->windowIsPopupType()) - QWindowSystemInterface::handleWindowActivated(0); + // key window will be non-nil if another window became key... do not + // set the active window to zero here, the new key window's + // NSWindowDidBecomeKeyNotification hander will change the active window + NSWindow *keyWindow = [NSApp keyWindow]; + if (!keyWindow) { + // no new key window, go ahead and set the active window to zero + if (!m_platformWindow->windowIsPopupType()) + QWindowSystemInterface::handleWindowActivated(0); + } } else if (notificationName == NSWindowDidMiniaturizeNotification) { QWindowSystemInterface::handleWindowStateChanged(m_window, Qt::WindowMinimized); } else if (notificationName == NSWindowDidDeminiaturizeNotification) { diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index c0242d95c5..578ea9f693 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -81,9 +81,6 @@ public: void tst_QGuiApplication::focusObject() { -#ifdef Q_OS_MAC - QSKIP("This test fails intermittently, and at different locations. See QTBUG-24322"); -#endif int argc = 0; QGuiApplication app(argc, 0);