Skip to content

Commit ea9ee87

Browse files
2 parents cc4b1d3 + 8efc661 commit ea9ee87

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/shell/contextmenu/contextmenu.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ std::vector<std::string> extract_hotkeys(const std::string &name) {
135135

136136
menu menu::construct_with_hmenu(
137137
HMENU hMenu, HWND hWnd, bool is_top,
138-
std::function<void(int, WPARAM, LPARAM)> HandleMenuMsg) {
138+
std::function<void(int, WPARAM, LPARAM)> HandleMenuMsg,
139+
LPARAM init_popup_lparam) {
139140
menu m;
140141

141142
if (!HandleMenuMsg)
@@ -144,7 +145,7 @@ menu menu::construct_with_hmenu(
144145
};
145146

146147
HandleMenuMsg(WM_INITMENUPOPUP, reinterpret_cast<WPARAM>(hMenu),
147-
0xFFFFFFFF);
148+
init_popup_lparam);
148149
for (int i = 0; i < GetMenuItemCount(hMenu); i++) {
149150
menu_item item;
150151
wchar_t buffer[256];
@@ -177,13 +178,12 @@ menu menu::construct_with_hmenu(
177178

178179
if (info.hSubMenu) {
179180
auto main_thread_id = GetCurrentThreadId();
181+
int submenu_pos = i;
180182
item.submenu = [=](std::shared_ptr<menu_widget> mw) {
181183
auto task = [&]() {
182-
HandleMenuMsg(WM_INITMENUPOPUP,
183-
reinterpret_cast<WPARAM>(info.hSubMenu),
184-
0xFFFFFFFF);
185184
mw->init_from_data(menu::construct_with_hmenu(
186-
info.hSubMenu, hWnd, false, HandleMenuMsg));
185+
info.hSubMenu, hWnd, false, HandleMenuMsg,
186+
MAKELPARAM(static_cast<WORD>(submenu_pos), 0)));
187187
};
188188
if (main_thread_id == GetCurrentThreadId())
189189
task();

src/shell/contextmenu/contextmenu.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ struct menu {
2020

2121
static menu
2222
construct_with_hmenu(HMENU hMenu, HWND hWnd, bool is_top = true,
23-
// This is for handling submenus; messages are required
24-
// to be forwarded to IContextMenu2::HandleMenuMsg for
25-
// submenus and owner-draw menus to work properly
2623
std::function<void(int, WPARAM, LPARAM)>
27-
HandleMenuMsg = {});
24+
HandleMenuMsg = {},
25+
LPARAM init_popup_lparam = 0xFFFFFFFF);
2826
};
2927

3028
std::optional<int>

0 commit comments

Comments
 (0)