diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2023-03-07 12:37:27 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2023-03-28 04:33:05 +0100 |
commit | 90d7fd58229d3b3fe04762ac53f686748c10a723 (patch) | |
tree | 5183c6c75b12e36cfc113c1e18614daace2e7e1f /src/plugins/platforms/cocoa/qcocoawindow.mm | |
parent | 41201f9d655ace09fdadf25626d5e728379939e7 (diff) |
macOS: Apply QWindow properties to NSWindow when setting content view
The main responsibility of QCocoaWindow::recreateWindowIfNeeded() is
to decide if the platform window is top level or not, and if so needs
an NSWindow or NSPanel accompanying it.
Once that decision has been made, and we've created an NSWindow or
NSPanel, and made the view the content view of this window, we need
to apply the QWindow properties to the newly created NSWindow or
NSPanel. But doing so in recreateWindowIfNeeded increases the
complexity and responsibilities of the function, so we move the
logic to [QNSWindow setContentView:] instead. This is analogous
to applying the properties during [QNSWindow init], but since we
are now the content view we can use the same code paths to apply
the initial properties as we use when they are updated later on.
Pick-to: 6.5
Change-Id: Idb4c812f4b22a029030bf4638357cf8628caea40
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoawindow.mm')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoawindow.mm | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 2083803c6d..3c3ff0e622 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1511,15 +1511,7 @@ void QCocoaWindow::recreateWindowIfNeeded() if (isEmbeddedView) { // An embedded window doesn't have its own NSWindow. - } else if (!parentWindow) { - // QPlatformWindow subclasses must sync up with QWindow on creation: - propagateSizeHints(); - setWindowFlags(window()->flags()); - setWindowTitle(window()->title()); - setWindowFilePath(window()->filePath()); // Also sets window icon - setWindowState(window()->windowState()); - setOpacity(window()->opacity()); - } else { + } else if (parentWindow) { // Child windows have no NSWindow, re-parent to superview instead [parentCocoaWindow->m_view addSubview:m_view]; [m_view setHidden:!window()->isVisible()]; |