From d6a36c521e3dbae591148c19b9ffcabc90cde99b Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Mon, 29 Aug 2022 10:43:45 +0800 Subject: Windows QPA: Don't highlight the first entry of the system menu if not appropriate Only menu brought up by keyboard should highlight the first entry, if the system menu is triggered by right clicking the title bar, there should be no highlighted menu items. What we do in QWindowsKeyMapper is not temporary changes, the first entry will always be highlighted unless we unhighlight it manually. Amends commit 64d65a645c3f64c6b317aed571366bc049c1cd25 Pick-to: 6.4 Change-Id: I22c887478fd928264bfa35b9b3a8b67e16a6c649 Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowskeymapper.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index 006396d92a..273bed6767 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -817,6 +817,12 @@ static void showSystemMenu(QWindow* w) pos.x(), pos.y() + titleBarOffset, topLevelHwnd, nullptr); + + // Remove the highlight of the restore menu item, otherwise when the user right-clicks + // on the title bar, the popuped system menu will also highlight the restore item, which + // is not appropriate, it should only be highlighted if the menu is brought up by keyboard. + HiliteMenuItem(topLevelHwnd, menu, SC_RESTORE, MF_BYCOMMAND | MFS_UNHILITE); + if (ret) qWindowsWndProc(topLevelHwnd, WM_SYSCOMMAND, WPARAM(ret), 0); } -- cgit v1.2.3