Vincent Povirk : server: Post WM_HOTKEY when a hotkey is pressed.

Alexandre Julliard julliard at winehq.org
Tue Jun 21 12:25:41 CDT 2011


Module: wine
Branch: master
Commit: cc0ea6986772f90b83358080178da9b3bb974378
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=cc0ea6986772f90b83358080178da9b3bb974378

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Thu May 26 15:52:17 2011 -0500

server: Post WM_HOTKEY when a hotkey is pressed.

---

 dlls/user32/tests/msg.c |    8 ++++----
 server/queue.c          |   37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 41 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 2fceacd..ce773a1 100644
--- a/server/queue.c
+++ b/server/queue.c
@@ -1316,6 +1316,42 @@ 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;
+    unsigned int modifiers = 0;
+
+    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_RWIN] & 0x80)) modifiers |= MOD_WIN;
+
+    LIST_FOR_EACH_ENTRY( hotkey, &desktop->hotkeys, struct hotkey, entry )
+    {
+        if (hotkey->vkey != msg->wparam) continue;
+        if ((hotkey->flags & (MOD_ALT|MOD_CONTROL|MOD_SHIFT|MOD_WIN)) == modifiers) goto found;
+    }
+
+    return 0;
+
+found:
+    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( &hotkey->queue->msg_list[POST_MESSAGE], &msg->entry );
+    set_queue_bits( hotkey->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 )
@@ -1358,6 +1394,7 @@ static void queue_hardware_message( struct desktop *desktop, struct message *msg
 
     if (is_keyboard_msg( msg ))
     {
+        if (queue_hotkey_message( desktop, msg )) return;
         if (desktop->keystate[VK_MENU] & 0x80) msg->lparam |= KF_ALTDOWN << 16;
         if (msg->wparam == VK_SHIFT || msg->wparam == VK_LSHIFT || msg->wparam == VK_RSHIFT)
             msg->lparam &= ~(KF_EXTENDED << 16);




More information about the wine-cvs mailing list