From 38c05fa6793b98bc38b7e6b1e0f02efd184fc802 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Thu, 26 May 2011 15:52:17 -0500 Subject: [PATCH 3/9] server: Post WM_HOTKEY when a hotkey is pressed. --- dlls/user32/tests/msg.c | 8 ++++---- server/queue.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index 7585c2c..ee1637d 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -13247,7 +13247,7 @@ static void test_hotkey(void) } DispatchMessage(&msg); } - ok_sequence(WmHotkeyPress, "window hotkey press", TRUE); + ok_sequence(WmHotkeyPress, "window hotkey press", FALSE); key_state = GetAsyncKeyState(hotkey_letter); ok((key_state & 0x8000) == 0x8000, "unexpected key state %x\n", key_state); @@ -13278,7 +13278,7 @@ static void test_hotkey(void) } DispatchMessage(&msg); } - ok_sequence(WmHotkeyCombined, "window hotkey combined", TRUE); + ok_sequence(WmHotkeyCombined, "window hotkey combined", FALSE); /* Register same hwnd/id with different key combination */ ret = RegisterHotKey(test_window, 5, 0, hotkey_letter); @@ -13307,7 +13307,7 @@ static void test_hotkey(void) } DispatchMessage(&msg); } - ok_sequence(WmHotkeyNew, "window hotkey new", TRUE); + ok_sequence(WmHotkeyNew, "window hotkey new", FALSE); /* Unregister hotkey properly */ ret = UnregisterHotKey(test_window, 5); @@ -13351,7 +13351,7 @@ static void test_hotkey(void) ok(msg.hwnd != NULL, "unexpected thread message %x\n", msg.message); DispatchMessage(&msg); } - ok_sequence(WmHotkeyPress, "thread hotkey press", TRUE); + ok_sequence(WmHotkeyPress, "thread hotkey press", FALSE); keybd_event(hotkey_letter, 0, KEYEVENTF_KEYUP, 0); while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) diff --git a/server/queue.c b/server/queue.c index cffdb32..938c0ec 100644 --- a/server/queue.c +++ b/server/queue.c @@ -1316,6 +1316,48 @@ static void release_hardware_message( struct msg_queue *queue, unsigned int hw_i } } +static int queue_hotkey_message( struct desktop *desktop, struct message *msg ) +{ + struct hotkey *hotkey; + int modifiers=0; + struct msg_queue *queue; + + if (msg->msg != WM_KEYDOWN) + return 0; + + if (desktop->keystate[VK_MENU] & 0x80) modifiers |= MOD_ALT; + if (desktop->keystate[VK_CONTROL] & 0x80) modifiers |= MOD_CONTROL; + if (desktop->keystate[VK_SHIFT] & 0x80) modifiers |= MOD_SHIFT; + if ((desktop->keystate[VK_LWIN] & 0x80) || (desktop->keystate[VK_LWIN] & 0x80)) modifiers |= MOD_WIN; + + LIST_FOR_EACH_ENTRY( hotkey, &desktop->hotkeys, struct hotkey, entry ) + { + if (hotkey->vkey == msg->wparam && + (hotkey->flags & (MOD_ALT|MOD_CONTROL|MOD_SHIFT|MOD_WIN)) == modifiers) + goto found; + } + + return 0; + +found: + queue = hotkey->queue; + + msg->type = MSG_POSTED; + msg->win = hotkey->win; + msg->msg = WM_HOTKEY; + msg->wparam = hotkey->id; + msg->lparam = ((hotkey->vkey & 0xffff) << 16) | modifiers; + + free( msg->data ); + msg->data = NULL; + msg->data_size = 0; + + list_add_tail( &queue->msg_list[POST_MESSAGE], &msg->entry ); + set_queue_bits( queue, QS_POSTMESSAGE|QS_ALLPOSTMESSAGE ); + + return 1; +} + /* find the window that should receive a given hardware message */ static user_handle_t find_hardware_message_window( struct desktop *desktop, struct thread_input *input, struct message *msg, unsigned int *msg_code ) @@ -1356,6 +1398,9 @@ static void queue_hardware_message( struct desktop *desktop, struct message *msg last_input_time = get_tick_count(); if (msg->msg != WM_MOUSEMOVE) always_queue = 1; + if (queue_hotkey_message( desktop, msg )) + return; + if (is_keyboard_msg( msg )) { if (desktop->keystate[VK_MENU] & 0x80) msg->lparam |= KF_ALTDOWN << 16; -- 1.7.1