macOS: Create NSView as initially hidden, to match QWindow behavior
Initially attempted in 096b56f336,
but that broke QQuickWindow::grabWindow(), which at the time was
not prepared for grabbing non-visible windows.
This is no longer an issue, as QQuickWindow::grabWindow() has fallback
logic for non-renderable windows. QWidget::grab() also works fine,
as it grabs from the backingstore directly.
For top level windows we apply the visibility state to both the
NSWindow (orderIn/Out), and to the NSView (hidden=YES/NO).
Pick-to: 6.5
Change-Id: I617b292ca6bfba66e65b55941c5b002e415da88d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
bb10
parent
6736118b8c
commit
a4bd121125
|
|
@ -338,6 +338,9 @@ void QCocoaWindow::setVisible(bool visible)
|
|||
|
||||
}
|
||||
|
||||
// Make the NSView visible first, before showing the NSWindow (in case of top level windows)
|
||||
m_view.hidden = NO;
|
||||
|
||||
if (isContentView()) {
|
||||
QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents);
|
||||
|
||||
|
|
@ -375,13 +378,6 @@ void QCocoaWindow::setVisible(bool visible)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// In some cases, e.g. QDockWidget, the content view is hidden before moving to its own
|
||||
// Cocoa window, and then shown again. Therefore, we test for the view being hidden even
|
||||
// if it's attached to an NSWindow.
|
||||
if ([m_view isHidden])
|
||||
[m_view setHidden:NO];
|
||||
|
||||
} else {
|
||||
// Window not visible, hide it
|
||||
if (isContentView()) {
|
||||
|
|
@ -410,10 +406,10 @@ void QCocoaWindow::setVisible(bool visible)
|
|||
if (mainWindow && [mainWindow canBecomeKeyWindow])
|
||||
[mainWindow makeKeyWindow];
|
||||
}
|
||||
} else {
|
||||
[m_view setHidden:YES];
|
||||
}
|
||||
|
||||
m_view.hidden = YES;
|
||||
|
||||
if (parentCocoaWindow && window()->type() == Qt::Popup) {
|
||||
NSWindow *nativeParentWindow = parentCocoaWindow->nativeWindow();
|
||||
if (m_resizableTransientParent
|
||||
|
|
@ -1514,7 +1510,6 @@ void QCocoaWindow::recreateWindowIfNeeded()
|
|||
} else if (parentWindow) {
|
||||
// Child windows have no NSWindow, re-parent to superview instead
|
||||
[parentCocoaWindow->m_view addSubview:m_view];
|
||||
[m_view setHidden:!window()->isVisible()];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -118,6 +118,13 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSViewMouseMoveHelper);
|
|||
if ((self = [super initWithFrame:NSZeroRect])) {
|
||||
m_platformWindow = platformWindow;
|
||||
|
||||
// NSViews are by default visible, but QWindows are not.
|
||||
// We should ideally pick up the actual QWindow state here,
|
||||
// but QWindowPrivate::setVisible() expects to control the
|
||||
// order of events tightly, so we need to wait for a call
|
||||
// to QCocoaWindow::setVisible().
|
||||
self.hidden = YES;
|
||||
|
||||
self.focusRingType = NSFocusRingTypeNone;
|
||||
|
||||
self.previousSuperview = nil;
|
||||
|
|
|
|||
Loading…
Reference in New Issue