From 7261c811528c4c05e3abbf4e30e8f0ad668921bb Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Mon, 14 Feb 2022 19:40:16 +0800 Subject: Windows QPA: fix window style correction for context help button MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Pick-to: 6.3 6.2 Change-Id: If32f8b42e25cfc67ffd1e84cc4b061f21a01042a Reviewed-by: André de la Rocha --- src/plugins/platforms/windows/qwindowswindow.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/plugins/platforms/windows/qwindowswindow.cpp') diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 1594a4057a..d28a3ee675 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -853,13 +853,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; -- cgit v1.2.3