[PATCH] user32: Add a heuristic to find the mouse message's window.

Huw Davies huw at codeweavers.com
Tue Feb 6 04:08:25 CST 2018


This can't be done properly without support from the native windowing
system.  However, it's a good bet to try the next window in the z-order
if it's the owner of the original window and it's in the same thread.

Signed-off-by: Huw Davies <huw at codeweavers.com>
---
 dlls/user32/message.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/dlls/user32/message.c b/dlls/user32/message.c
index 172d6593f6..6b7f91854f 100644
--- a/dlls/user32/message.c
+++ b/dlls/user32/message.c
@@ -2502,7 +2502,16 @@ static BOOL process_mouse_message( MSG *msg, UINT hw_id, ULONG_PTR extra_info, H
     }
     else
     {
+        HWND orig = msg->hwnd;
+
         msg->hwnd = WINPOS_WindowFromPoint( msg->hwnd, msg->pt, &hittest );
+        if (!msg->hwnd) /* As a heuristic, try the next window if it's the owner of orig */
+        {
+            HWND next = GetWindow( orig, GW_HWNDNEXT );
+
+            if (next && GetWindow( orig, GW_OWNER ) == next && WIN_IsCurrentThread( next ))
+                msg->hwnd = WINPOS_WindowFromPoint( next, msg->pt, &hittest );
+        }
     }
 
     if (!msg->hwnd || !WIN_IsCurrentThread( msg->hwnd ))
-- 
2.12.0




More information about the wine-devel mailing list