macOS: Preserve styleMask bits that we don't control when updating mask

We use QCocoaWindow::windowStyleMask to compute a new styleMask for the
NSWindow, based on the QWindow flags. However, some styleMask bits we
do not control in this function, so we need to preserve them in case
they were already set on the NSWindow, as otherwise we end up clearing
those bits. We did this already for NSWindowStyleMaskFullScreen, but now
we do it for all style mask bits we don't control.

This fixes an issue after QCocoaWindow::applyContentBorderThickness()
started calling setWindowFlags to control NSWindowStyleMaskTexturedBackground,
after the introduction of the Qt::NoTitleBarBackgroundHint window flag in
a1e6fed44964a3eb14045bf819d232d6cbad9f59 and then
bddc0198297828ba29e5cf4b39e07412a506a551.

The symptom was losing the NSWindowStyleMaskDocModalWindow style mask
for sheets or other modal windows with a QTabWidget in them, as that
widget ends up calling applyContentBorderThickness().

Fixes: QTBUG-134447
Pick-to: 6.9 dev
Change-Id: Ie3e9ca3ff14f84ce70438d3633bd283fb78b9e8c
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Tor Arne Vestbø 2025-03-06 16:09:05 +01:00
parent 3a8ac066e8
commit b90b473ee0

View File

@ -649,9 +649,13 @@ NSUInteger QCocoaWindow::windowStyleMask(Qt::WindowFlags flags)
if (flags & Qt::ExpandedClientAreaHint)
styleMask |= NSWindowStyleMaskFullSizeContentView;
// Don't wipe existing states
if (m_view.window.styleMask & NSWindowStyleMaskFullScreen)
styleMask |= NSWindowStyleMaskFullScreen;
// Don't wipe existing states for style flags we don't control here
styleMask |= (m_view.window.styleMask & (
NSWindowStyleMaskFullScreen
| NSWindowStyleMaskUnifiedTitleAndToolbar
| NSWindowStyleMaskDocModalWindow
| NSWindowStyleMaskNonactivatingPanel
| NSWindowStyleMaskHUDWindow));
return styleMask;
}