macOS: Remove special handling for hiding tool windows on application hide
The code was needed when we had QCocoaWindow::hide(), that guarded the ordering out by checking the visible state of the NSWindow. We no longer have that method, and setVisible doesn't have the same guard. Added a comment in setVisible to prevent future travelers from adding logic that introduces the same situation. Change-Id: I0514619a303daceb1cd7d334f0de4bfce6c3e96f Reviewed-by: Andy Shaw <andy.shaw@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>bb10
parent
4c75934008
commit
2fc4635e98
|
|
@ -94,7 +94,6 @@ QT_USE_NAMESPACE
|
|||
bool startedQuit;
|
||||
NSObject <NSApplicationDelegate> *reflectionDelegate;
|
||||
bool inLaunch;
|
||||
QWindowList hiddenWindows;
|
||||
}
|
||||
|
||||
+ (instancetype)sharedDelegate
|
||||
|
|
@ -311,41 +310,6 @@ QT_USE_NAMESPACE
|
|||
return NO; // Someday qApp->quitOnLastWindowClosed(); when QApp and NSApp work closer together.
|
||||
}
|
||||
|
||||
- (void)applicationWillHide:(NSNotification *)notification
|
||||
{
|
||||
if (reflectionDelegate
|
||||
&& [reflectionDelegate respondsToSelector:@selector(applicationWillHide:)]) {
|
||||
[reflectionDelegate applicationWillHide:notification];
|
||||
}
|
||||
|
||||
// When the application is hidden Qt will hide the popup windows associated with
|
||||
// it when it has lost the activation for the application. However, when it gets
|
||||
// to this point it believes the popup windows to be hidden already due to the
|
||||
// fact that the application itself is hidden, which will cause a problem when
|
||||
// the application is made visible again.
|
||||
const QWindowList topLevelWindows = QGuiApplication::topLevelWindows();
|
||||
for (QWindow *topLevelWindow : topLevelWindows) {
|
||||
if ((topLevelWindow->type() & Qt::Popup) == Qt::Popup && topLevelWindow->isVisible()) {
|
||||
topLevelWindow->hide();
|
||||
|
||||
if ((topLevelWindow->type() & Qt::Tool) == Qt::Tool)
|
||||
hiddenWindows << topLevelWindow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)applicationDidUnhide:(NSNotification *)notification
|
||||
{
|
||||
if (reflectionDelegate
|
||||
&& [reflectionDelegate respondsToSelector:@selector(applicationDidUnhide:)])
|
||||
[reflectionDelegate applicationDidUnhide:notification];
|
||||
|
||||
for (QWindow *window : qAsConst(hiddenWindows))
|
||||
window->show();
|
||||
|
||||
hiddenWindows.clear();
|
||||
}
|
||||
|
||||
- (void)applicationDidBecomeActive:(NSNotification *)notification
|
||||
{
|
||||
if (reflectionDelegate
|
||||
|
|
|
|||
|
|
@ -400,6 +400,11 @@ void QCocoaWindow::setVisible(bool visible)
|
|||
}
|
||||
}
|
||||
|
||||
// Note: We do not guard the order out by checking NSWindow.visible, as AppKit will
|
||||
// in some cases, such as when hiding the application, order out and make a window
|
||||
// invisible, but keep it in a list of "hidden windows", that it then restores again
|
||||
// when the application is unhidden. We need to call orderOut explicitly, to bring
|
||||
// the window out of this "hidden list".
|
||||
[m_view.window orderOut:nil];
|
||||
|
||||
if (m_view.window == [NSApp keyWindow] && !eventDispatcher()->hasModalSession()) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue