[2/2] comctl32: Fix message sequence on right mouse click

Daniel Jelinski djelinski1 at gmail.com
Sat Apr 7 13:54:25 CDT 2012


Tested on Linux with both native and builtin comctl32.dll. Not tested
on Windows.
-------------- next part --------------
From a9ef348c45d205c5f55f6872803aeb2771d3b7bb Mon Sep 17 00:00:00 2001
From: Daniel Jelinski <djelinski1 at gmail.com>
Date: Sat, 7 Apr 2012 20:26:31 +0200
Subject: comctl32: Fix message sequence on right mouse click

WM_CONTEXTMENU should be sent to parent window only, and only if it isn't blocked by return value from NM_CLICK.
This resolves the issue from bug #19222
---
 dlls/comctl32/tests/treeview.c |    6 ++----
 dlls/comctl32/treeview.c       |   15 +++++++--------
 2 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/dlls/comctl32/tests/treeview.c b/dlls/comctl32/tests/treeview.c
index a2a20e7..4eb8701 100644
--- a/dlls/comctl32/tests/treeview.c
+++ b/dlls/comctl32/tests/treeview.c
@@ -1883,10 +1883,8 @@ static void test_mouse(void)
     PostMessageA(hTree, WM_RBUTTONUP, 0, (LPARAM)0x10001);
     SendMessageA(hTree, WM_RBUTTONDOWN, 2, (LPARAM)0x10001);
 
-    /* rclick should send NM_RCLICK and then, only if it returns 0, WM_CONTEXTMENU to parent.
-     Instead it sends WM_CONTEXTMENU to self, and then NM_RCLICK  to parent */
-    ok_sequence(sequences, PARENT_SEQ_INDEX, parent_rclick_seq, "right click (parent)", TRUE);
-    ok_sequence(sequences, TREEVIEW_SEQ_INDEX, tree_rclick_seq, "right click (tree)", TRUE);
+    ok_sequence(sequences, PARENT_SEQ_INDEX, parent_rclick_seq, "right click (parent)", FALSE);
+    ok_sequence(sequences, TREEVIEW_SEQ_INDEX, tree_rclick_seq, "right click (tree)", FALSE);
 
     flush_sequences(sequences, NUM_MSG_SEQUENCES);
     /* now test dragging - rbuttondown, mousemove, rbuttonup */
diff --git a/dlls/comctl32/treeview.c b/dlls/comctl32/treeview.c
index 3f4fdc6..85daac9 100644
--- a/dlls/comctl32/treeview.c
+++ b/dlls/comctl32/treeview.c
@@ -4248,11 +4248,6 @@ TREEVIEW_RButtonDown(TREEVIEW_INFO *infoPtr, LPARAM lParam)
 	    infoPtr->dropItem = ht.hItem;
 	}
     }
-    else
-    {
-	SetFocus(infoPtr->hwnd);
-	TREEVIEW_SendSimpleNotify(infoPtr, NM_RCLICK);
-    }
 
     return 0;
 }
@@ -4271,9 +4266,13 @@ TREEVIEW_RButtonUp(const TREEVIEW_INFO *infoPtr, const POINT *pPt)
         /* Change to screen coordinate for WM_CONTEXTMENU */
         ClientToScreen(infoPtr->hwnd, &ht.pt);
 
-        /* Send a WM_CONTEXTMENU message in response to the RBUTTONUP */
-        SendMessageW(infoPtr->hwnd, WM_CONTEXTMENU,
-            (WPARAM)infoPtr->hwnd, MAKELPARAM(ht.pt.x, ht.pt.y));
+        SetFocus(infoPtr->hwnd);
+        if (!TREEVIEW_SendSimpleNotify(infoPtr, NM_RCLICK))
+        {
+            /* Send a WM_CONTEXTMENU message in response to the RBUTTONUP */
+            SendMessageW(infoPtr->hwndNotify, WM_CONTEXTMENU,
+                (WPARAM)infoPtr->hwnd, MAKELPARAM(ht.pt.x, ht.pt.y));
+        }
     }
     return 0;
 }
-- 
1.7.5.4


More information about the wine-patches mailing list