Signed-off-by: Ziqing Hui zhui@codeweavers.com --- dlls/user32/tests/msg.c | 81 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 2 deletions(-)
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index 4b2495f4197..73737eab98b 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -17359,6 +17359,29 @@ static const struct message WmHotkeyNew[] = { { WM_KEYUP, sent, 0, 0x80000001 }, /* lparam not checked so the sequence isn't a todo */ { 0 } }; +static const struct message WmHotkeyPressALT[] = { + { WM_SYSKEYDOWN, kbd_hook|wparam|lparam, VK_LMENU, LLKHF_INJECTED|LLKHF_ALTDOWN }, + { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, + { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 }, + { 0 } +}; +static const struct message WmHotkeyPressWithALT[] = { + { WM_SYSKEYDOWN, kbd_hook, 0, LLKHF_INJECTED|LLKHF_ALTDOWN }, /* lparam not checked */ + { WM_HOTKEY, sent|wparam, 6 }, + { 0 } +}; +static const struct message WmHotkeyReleaseWithALT[] = { + { WM_SYSKEYUP, kbd_hook|lparam, 0, LLKHF_INJECTED|LLKHF_UP|LLKHF_ALTDOWN }, + { HCBT_KEYSKIPPED, hook|lparam|optional, 0, 0xa0000001 }, + { WM_SYSKEYUP, sent|lparam, 0, 0xa0000001 }, + { 0 } +}; +static const struct message WmHotkeyReleaseALT[] = { + { WM_KEYUP, kbd_hook|wparam|lparam, VK_LMENU, LLKHF_INJECTED|LLKHF_UP }, + { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, + { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 }, + { 0 } +};
static int hotkey_letter;
@@ -17378,9 +17401,12 @@ static LRESULT CALLBACK KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam msg.descr = "KeyboardHookProc"; add_message(&msg);
- if (wParam == WM_KEYUP || wParam == WM_KEYDOWN) + if (wParam == WM_KEYUP || wParam == WM_KEYDOWN || + wParam == WM_SYSKEYUP || wParam == WM_SYSKEYDOWN) { - ok(kdbhookstruct->vkCode == VK_LWIN || kdbhookstruct->vkCode == hotkey_letter, + ok(kdbhookstruct->vkCode == VK_LWIN || + kdbhookstruct->vkCode == VK_LMENU || + kdbhookstruct->vkCode == hotkey_letter, "unexpected keycode %x\n", kdbhookstruct->vkCode); } } @@ -17635,6 +17661,56 @@ static void test_hotkey(void) } ok_sequence(WmHotkeyReleaseLWIN, "thread hotkey release LWIN", FALSE);
+ /* Search for an ALT + letter combination that hasn't been registered */ + for (hotkey_letter = 0x41; hotkey_letter <= 0x51; hotkey_letter ++) + { + SetLastError(0xdeadbeef); + ret = RegisterHotKey(test_window, 6, MOD_ALT, hotkey_letter); + + if (ret == TRUE) + { + break; + } + else + { + ok(GetLastError() == ERROR_HOTKEY_ALREADY_REGISTERED || broken(GetLastError() == 0xdeadbeef), + "unexpected error %d\n", GetLastError()); + } + } + + if (hotkey_letter == 0x52) + { + ok(0, "Couldn't find any free ALT + letter combination\n"); + goto end; + } + + keybd_event(VK_LMENU, 0, 0, 0); + while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) + DispatchMessageA(&msg); + ok_sequence(WmHotkeyPressALT, "window hotkey press ALT", TRUE); + + keybd_event(hotkey_letter, 0, 0, 0); + while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) + { + if (msg.message == WM_HOTKEY) + { + ok(msg.hwnd == test_window, "unexpected hwnd %p\n", msg.hwnd); + ok(msg.lParam == MAKELPARAM(MOD_ALT, hotkey_letter), "unexpected WM_HOTKEY lparam %lx\n", msg.lParam); + } + DispatchMessageA(&msg); + } + ok_sequence(WmHotkeyPressWithALT, "window hotkey press with ALT", TRUE); + + keybd_event(hotkey_letter, 0, KEYEVENTF_KEYUP, 0); + while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) + DispatchMessageA(&msg); + ok_sequence(WmHotkeyReleaseWithALT, "window hotkey release with ALT", TRUE); + + keybd_event(VK_LMENU, 0, KEYEVENTF_KEYUP, 0); + while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) + DispatchMessageA(&msg); + ok_sequence(WmHotkeyReleaseALT, "window hotkey release ALT", FALSE); + /* Unregister thread hotkey */ ret = UnregisterHotKey(NULL, 5); ok(ret == TRUE, "expected TRUE, got %i, err=%d\n", ret, GetLastError()); @@ -17645,6 +17721,7 @@ static void test_hotkey(void) end: UnregisterHotKey(NULL, 5); UnregisterHotKey(test_window, 5); + UnregisterHotKey(test_window, 6); DestroyWindow(test_window); flush_sequence(); }
ALT and F10 key generate WM_SYSKEYDOWN message. They should also have the ability to queue hotkey message.
Signed-off-by: Ziqing Hui zhui@codeweavers.com --- dlls/user32/tests/msg.c | 2 +- server/queue.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index 73737eab98b..c054a145112 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -17699,7 +17699,7 @@ static void test_hotkey(void) } DispatchMessageA(&msg); } - ok_sequence(WmHotkeyPressWithALT, "window hotkey press with ALT", TRUE); + ok_sequence(WmHotkeyPressWithALT, "window hotkey press with ALT", FALSE);
keybd_event(hotkey_letter, 0, KEYEVENTF_KEYUP, 0); while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) diff --git a/server/queue.c b/server/queue.c index 63a3a1fe2db..f7bc28f39e9 100644 --- a/server/queue.c +++ b/server/queue.c @@ -1422,7 +1422,7 @@ static int queue_hotkey_message( struct desktop *desktop, struct message *msg ) struct hotkey *hotkey; unsigned int modifiers = 0;
- if (msg->msg != WM_KEYDOWN) return 0; + if (msg->msg != WM_KEYDOWN && msg->msg != WM_SYSKEYDOWN) return 0;
if (desktop->keystate[VK_MENU] & 0x80) modifiers |= MOD_ALT; if (desktop->keystate[VK_CONTROL] & 0x80) modifiers |= MOD_CONTROL;
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=101136
Your paranoid android.
=== w8adm (32 bit report) ===
user32: msg.c:15240: Test failed: unexpected message 31f msg.c:15241: Test failed: bad wparam 1 msg.c:15247: Test failed: unicode WM_CHAR: 0: the msg sequence is not complete: expected 0102 - actual 0000
=== w10pro64_he (64 bit report) ===
user32: msg.c:12806: Test failed: message time not advanced: b9ba b9ba msg.c:12807: Test failed: coords not changed: (101 101) (101 101) msg.c:12824: Test failed: message time not advanced: b9ba b9ba msg.c:12825: Test failed: coords not changed: (101 101) (101 101)