diff options
author | Yuhang Zhao <2546789017@qq.com> | 2022-02-14 19:40:16 +0800 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-03-03 02:08:58 +0000 |
commit | fc4740087d43f16e1dc905327f25ceb3f9ce1438 (patch) | |
tree | eee53804091383c78593690289b69e69b72a569f /src/plugins/platforms | |
parent | 7e9535f8c71dbc956f0f1b46817a86d5ab937891 (diff) |
Windows QPA: fix window style correction for context help button
According to Microsoft Docs [1][2], WS_MINIMIZEBOX and WS_MAXIMIZEBOX
must be accompanied by the WS_SYSMENU style, and the WS_EX_CONTEXTHELP
style is not compatible with WS_MINIMIZEBOX and WS_MAXIMIZEBOX. This
patch adds additional checks for these situations.
[1] https://docs.microsoft.com/en-us/windows/win32/winmsg/window-styles
[2] https://docs.microsoft.com/en-us/windows/win32/winmsg/extended-window-styles
Change-Id: If32f8b42e25cfc67ffd1e84cc4b061f21a01042a
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
(cherry picked from commit 7261c811528c4c05e3abbf4e30e8f0ad668921bb)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r-- | src/plugins/platforms/windows/qwindowswindow.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index ce2f30478d..07591b91db 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -779,13 +779,18 @@ void WindowCreationData::fromWindow(const QWindow *w, const Qt::WindowFlags flag style |= WS_SYSMENU | WS_BORDER; // QTBUG-2027, dialogs without system menu. exStyle |= WS_EX_DLGMODALFRAME; } - if (flags & Qt::WindowMinimizeButtonHint) + const bool showMinimizeButton = flags & Qt::WindowMinimizeButtonHint; + if (showMinimizeButton) style |= WS_MINIMIZEBOX; - if (shouldShowMaximizeButton(w, flags)) + const bool showMaximizeButton = shouldShowMaximizeButton(w, flags); + if (showMaximizeButton) style |= WS_MAXIMIZEBOX; + if (showMinimizeButton || showMaximizeButton) + style |= WS_SYSMENU; if (tool) exStyle |= WS_EX_TOOLWINDOW; - if (flags & Qt::WindowContextHelpButtonHint) + if ((flags & Qt::WindowContextHelpButtonHint) && !showMinimizeButton + && !showMaximizeButton) exStyle |= WS_EX_CONTEXTHELP; } else { exStyle |= WS_EX_TOOLWINDOW; |