summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYuhang Zhao <2546789017@qq.com>2022-02-07 17:48:00 +0800
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-02-25 04:43:28 +0000
commit7b7929af6c58180e475b8f8f9ba299d0bdfca4ec (patch)
treeef4ff47e497b65d31e4e0286e9ce674ffeb9f8f1 /src
parent6d5e44ffbdd2f9cf7181f59ec89ff9da2d3443b6 (diff)
Windows QPA: Highlight the first entry in the system menu
This is what native Win32 applications usually do. Change-Id: I19f1170113b4064f1d683dbd13b7de7d263105f0 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: André de la Rocha <andre.rocha@qt.io> (cherry picked from commit 64d65a645c3f64c6b317aed571366bc049c1cd25) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/windows/qwindowskeymapper.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp
index 7365401089..5954f35b07 100644
--- a/src/plugins/platforms/windows/qwindowskeymapper.cpp
+++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp
@@ -800,7 +800,6 @@ static void showSystemMenu(QWindow* w)
bool maximized = IsZoomed(topLevelHwnd);
EnableMenuItem(menu, SC_MAXIMIZE, ! (topLevel->flags() & Qt::WindowMaximizeButtonHint) || maximized?disabled:enabled);
- EnableMenuItem(menu, SC_RESTORE, maximized?enabled:disabled);
// We should _not_ check with the setFixedSize(x,y) case here, since Windows is not able to check
// this and our menu here would be out-of-sync with the menu produced by mouse-click on the
@@ -808,6 +807,15 @@ static void showSystemMenu(QWindow* w)
EnableMenuItem(menu, SC_SIZE, (topLevel->flags() & Qt::MSWindowsFixedSizeDialogHint) || maximized?disabled:enabled);
EnableMenuItem(menu, SC_MOVE, maximized?disabled:enabled);
EnableMenuItem(menu, SC_CLOSE, enabled);
+
+ // Highlight the first entry in the menu, this is what native Win32 applications usually do.
+ MENUITEMINFOW restoreItem;
+ SecureZeroMemory(&restoreItem, sizeof(restoreItem));
+ restoreItem.cbSize = sizeof(restoreItem);
+ restoreItem.fMask = MIIM_STATE;
+ restoreItem.fState = MFS_HILITE | (maximized ? MFS_ENABLED : MFS_GRAYED);
+ SetMenuItemInfoW(menu, SC_RESTORE, FALSE, &restoreItem);
+
// Set bold on close menu item
MENUITEMINFO closeItem;
closeItem.cbSize = sizeof(MENUITEMINFO);