user32: Properly handle WM_DEVICECHANGE in is_pointer_message().
authorQian Hong <qhong@codeweavers.com>
Wed, 30 Dec 2015 09:13:49 +0000 (17:13 +0800)
committerAlexandre Julliard <julliard@winehq.org>
Wed, 30 Dec 2015 16:27:52 +0000 (17:27 +0100)
Signed-off-by: Qian Hong <qhong@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
dlls/user32/message.c
dlls/user32/tests/msg.c

index 96e7f2e7dcde73a52375a4e783a41278319b31bd..ba3f4c6d86d8bbc7cbcbbd1d0adc0799349d518d 100644 (file)
@@ -422,9 +422,10 @@ static const unsigned int message_unicode_flags[] =
 };
 
 /* check whether a given message type includes pointers */
-static inline BOOL is_pointer_message( UINT message )
+static inline BOOL is_pointer_message( UINT message, WPARAM wparam )
 {
     if (message >= 8*sizeof(message_pointer_flags)) return FALSE;
+    if (message == WM_DEVICECHANGE && !(wparam & 0x8000)) return FALSE;
     return (message_pointer_flags[message / 32] & SET(message)) != 0;
 }
 
@@ -3490,7 +3491,7 @@ BOOL WINAPI SendNotifyMessageA( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpara
 {
     struct send_message_info info;
 
-    if (is_pointer_message(msg))
+    if (is_pointer_message( msg, wparam ))
     {
         SetLastError( ERROR_MESSAGE_SYNC_ONLY );
         return FALSE;
@@ -3515,7 +3516,7 @@ BOOL WINAPI SendNotifyMessageW( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpara
 {
     struct send_message_info info;
 
-    if (is_pointer_message(msg))
+    if (is_pointer_message( msg, wparam ))
     {
         SetLastError( ERROR_MESSAGE_SYNC_ONLY );
         return FALSE;
@@ -3540,7 +3541,7 @@ BOOL WINAPI SendMessageCallbackA( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
 {
     struct send_message_info info;
 
-    if (is_pointer_message(msg))
+    if (is_pointer_message( msg, wparam ))
     {
         SetLastError( ERROR_MESSAGE_SYNC_ONLY );
         return FALSE;
@@ -3568,7 +3569,7 @@ BOOL WINAPI SendMessageCallbackW( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
 {
     struct send_message_info info;
 
-    if (is_pointer_message(msg))
+    if (is_pointer_message( msg, wparam ))
     {
         SetLastError( ERROR_MESSAGE_SYNC_ONLY );
         return FALSE;
@@ -3638,7 +3639,7 @@ BOOL WINAPI PostMessageW( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
 {
     struct send_message_info info;
 
-    if (is_pointer_message( msg ))
+    if (is_pointer_message( msg, wparam ))
     {
         SetLastError( ERROR_MESSAGE_SYNC_ONLY );
         return FALSE;
@@ -3687,7 +3688,7 @@ BOOL WINAPI PostThreadMessageW( DWORD thread, UINT msg, WPARAM wparam, LPARAM lp
 {
     struct send_message_info info;
 
-    if (is_pointer_message( msg ))
+    if (is_pointer_message( msg, wparam ))
     {
         SetLastError( ERROR_MESSAGE_SYNC_ONLY );
         return FALSE;
index 7204d1983b6d13698ef5fa05b2a427e5f4f40f1d..bf1dab28f1e160d240062b7a411724c848a8ace5 100644 (file)
@@ -4553,13 +4553,11 @@ static void test_WM_DEVICECHANGE(HWND hwnd)
         }
         else
         {
-            todo_wine {
-                ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
-                ok(ret == WAIT_OBJECT_0, "MsgWaitForMultipleObjects returned %x\n", ret);
-                memset(&msg, 0, sizeof(msg));
-                ok(PeekMessageA(&msg, 0, 0, 0, PM_REMOVE), "PeekMessage should succeed\n");
-                ok(msg.message == WM_DEVICECHANGE, "got %04x instead of WM_DEVICECHANGE\n", msg.message);
-            }
+            ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
+            ok(ret == WAIT_OBJECT_0, "MsgWaitForMultipleObjects returned %x\n", ret);
+            memset(&msg, 0, sizeof(msg));
+            ok(PeekMessageA(&msg, 0, 0, 0, PM_REMOVE), "PeekMessage should succeed\n");
+            ok(msg.message == WM_DEVICECHANGE, "got %04x instead of WM_DEVICECHANGE\n", msg.message);
         }
     }
 }