diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2017-08-08 15:27:53 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2017-08-11 13:08:24 +0000 |
commit | 096b56f336e5bb994d46f073d55496d36d38e6b1 (patch) | |
tree | 020f9d3aa3db11c369c57a03152346dd17c34ded /src/plugins/platforms/cocoa | |
parent | 255abc1e5a3397bf14e9854388881cd80f0bd2e3 (diff) |
macOS: Create NSView as initially hidden, to match QWindow behavior
Change-Id: I25af6635ea9b6aa3fcc642fa2da0553341aabda8
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoawindow.mm | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 9f98ad56de..7a19303f5d 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -178,6 +178,11 @@ void QCocoaWindow::initialize() if (!m_view) { m_view = [[QNSView alloc] initWithCocoaWindow:this]; + + // NSViews are visible by default, as opposed to QWindows which are not, + // so make the view hidden until we receive an explicit setVisible. + m_view.hidden = YES; + // Enable high-dpi OpenGL for retina displays. Enabling has the side // effect that Cocoa will start calling glViewport(0, 0, width, height), // overriding any glViewport calls in application code. This is usually not a @@ -343,9 +348,11 @@ void QCocoaWindow::setVisible(bool visible) && !(nativeParentWindow.styleMask & NSFullScreenWindowMask)) nativeParentWindow.styleMask &= ~NSResizableWindowMask; } - } + // 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); @@ -395,11 +402,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 { // qDebug() << "close" << this; #ifndef QT_NO_OPENGL @@ -435,7 +437,7 @@ void QCocoaWindow::setVisible(bool visible) [mainWindow makeKeyWindow]; } } else { - [m_view setHidden:YES]; + m_view.hidden = YES; } removeMonitor(); @@ -1235,7 +1237,6 @@ void QCocoaWindow::recreateWindowIfNeeded() rect.setSize(QSize(1, 1)); NSRect frame = NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height()); [m_view setFrame:frame]; - [m_view setHidden:!window()->isVisible()]; } const qreal opacity = qt_window_private(window())->opacity; |