From: Fabian Maurer <dark.shadow4@web.de>
Subject: [PATCH] user32: Allow activating desktop only when clicked directly
Message-Id: <20170829010703.7264-1-dark.shadow4@web.de>
Date: Tue, 29 Aug 2017 03:07:03 +0200

Fixes the regression for bug Bug 43577
introduced in ae153a5c2c5590d4ea722d38eb4ddf1a7031f34a,
while keeping the feature it added.

Some programs have toplevel windows that have WS_CHILD set.
If one of those is clicked, it would activate the desktop,
but it shouldn't.

Signed-off-by: Fabian Maurer <dark.shadow4@web.de>
---
 dlls/user32/message.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/dlls/user32/message.c b/dlls/user32/message.c
index 3d3736d9c6..6e7779b853 100644
--- a/dlls/user32/message.c
+++ b/dlls/user32/message.c
@@ -2638,13 +2638,16 @@ static BOOL process_mouse_message( MSG *msg, UINT hw_id, ULONG_PTR extra_info, H
         if (msg->hwnd != info.hwndActive)
         {
             HWND hwndTop = msg->hwnd;
+            HWND desktop = GetDesktopWindow();
             while (hwndTop)
             {
                 if ((GetWindowLongW( hwndTop, GWL_STYLE ) & (WS_POPUP|WS_CHILD)) != WS_CHILD) break;
                 hwndTop = GetParent( hwndTop );
             }
 
-            if (hwndTop)
+            /* Can activate desktop, but only if it was clicked directly
+             * This check is needed since some top-level windows have WS_CHILD set */
+            if (hwndTop && (msg->hwnd == desktop || hwndTop != desktop))
             {
                 LONG ret = SendMessageW( msg->hwnd, WM_MOUSEACTIVATE, (WPARAM)hwndTop,
                                          MAKELONG( hittest, msg->message ) );

-- 
2.14.1