[PATCH v3] user32: Don't send WM_CHAR when a menu gets VK_ESCAPE and add tests
Fabian Maurer
dark.shadow4 at web.de
Mon Jan 30 07:51:28 CST 2017
Fixes https://bugs.winehq.org/show_bug.cgi?id=41489
v2: Moved and improved test
v3: Don't translate message instead of removing WM_CHAR
Signed-off-by: Fabian Maurer <dark.shadow4 at web.de>
---
dlls/user32/menu.c | 4 +++-
dlls/user32/tests/msg.c | 19 +++++++++++++++++++
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c
index 59fcd9c488..a4d59713c9 100644
--- a/dlls/user32/menu.c
+++ b/dlls/user32/menu.c
@@ -3077,7 +3077,9 @@ static BOOL MENU_TrackMenu( HMENU hmenu, UINT wFlags, INT x, INT y,
break;
}
- TranslateMessage( &msg );
+ /* Don't translate escape-keydown message because it leads to an unexpected WM_CHAR */
+ if( !(msg.message == WM_KEYDOWN && msg.wParam == VK_ESCAPE) )
+ TranslateMessage( &msg );
mt.pt = msg.pt;
if ( (msg.hwnd==menu->hWnd) || (msg.message!=WM_TIMER) )
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c
index 45b5222deb..36a162fd30 100644
--- a/dlls/user32/tests/msg.c
+++ b/dlls/user32/tests/msg.c
@@ -1675,6 +1675,10 @@ static const struct message WmTrackPopupMenu[] = {
{ 0 }
};
+static const struct message WmTrackPopupMenuEsc[] = {
+ { 0 }
+};
+
static const struct message WmTrackPopupMenuCapture[] = {
{ HCBT_CREATEWND, hook },
{ WM_ENTERMENULOOP, sent|wparam|lparam, TRUE, 0 },
@@ -15637,6 +15641,7 @@ static LRESULT WINAPI cancel_init_proc(HWND hwnd, UINT message, WPARAM wParam, L
static void test_TrackPopupMenu(void)
{
+ MSG msg;
HWND hwnd;
BOOL ret;
@@ -15659,6 +15664,20 @@ static void test_TrackPopupMenu(void)
ok_sequence(WmTrackPopupMenu, "TrackPopupMenu", TRUE);
ok(ret == 1, "TrackPopupMenu failed with error %i\n", GetLastError());
+ /* Test popup closing with an ESC-press */
+ flush_events();
+ PostMessageW(hwnd, WM_KEYDOWN, VK_ESCAPE, 0);
+ ret = TrackPopupMenu(hpopupmenu, 0, 100,100, 0, hwnd, NULL);
+ ok(ret == 1, "TrackPopupMenu failed with error %i\n", GetLastError());
+ PostQuitMessage(0);
+ flush_sequence();
+ while ( PeekMessageA(&msg, 0, 0, 0, PM_REMOVE) )
+ {
+ TranslateMessage(&msg);
+ DispatchMessageA(&msg);
+ }
+ ok_sequence(WmTrackPopupMenuEsc, "TrackPopupMenu", FALSE); /* Shouldn't get any message */
+
SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR)cancel_init_proc);
flush_events();
--
2.11.0
More information about the wine-patches
mailing list