Fix the issue of incorrect linkid calculation due to a lack of judgment on the current type.
Signed-off-by: Zhaoyi zhaoyi@uniontech.com
-- v13: comctl32/syslink: Check item type before increasing link ID in SYSLINK_LinkAtPt().
From: Zhaoyi zhaoyi@uniontech.com
Signed-off-by: Zhaoyi zhaoyi@uniontech.com --- dlls/comctl32/tests/syslink.c | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
diff --git a/dlls/comctl32/tests/syslink.c b/dlls/comctl32/tests/syslink.c index d5192c26b5c..c0bdfdaf0b9 100644 --- a/dlls/comctl32/tests/syslink.c +++ b/dlls/comctl32/tests/syslink.c @@ -30,6 +30,7 @@ #define SYSLINK_SEQ_INDEX 1
static HWND hWndParent; +static int g_link_id;
static struct msg_sequence *sequences[NUM_MSG_SEQUENCE];
@@ -99,6 +100,20 @@ static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LP add_message(sequences, PARENT_SEQ_INDEX, &msg); }
+ switch(message) + { + case WM_NOTIFY: + { + NMLINK *nml = ((NMLINK *)lParam); + if (nml && NM_CLICK == nml->hdr.code) + { + g_link_id = nml->item.iLink; + } + break; + } + default: + break; + } defwndproc_counter++; ret = DefWindowProcW(hwnd, message, wParam, lParam); defwndproc_counter--; @@ -238,6 +253,28 @@ static void test_LM_GETIDEALSIZE(void) DestroyWindow(hwnd); }
+static void test_link_id(void) +{ + HWND hwnd; + + hwnd = create_syslink(WS_CHILD | WS_TABSTOP | WS_VISIBLE, hWndParent); + ok(hwnd != NULL, "Failed to create SysLink window.\n"); + + /* test link1 at (50, 10) */ + g_link_id = 0; + SendMessageA(hwnd, WM_LBUTTONDOWN, 1, MAKELPARAM(50, 10)); + SendMessageA(hwnd, WM_LBUTTONUP, 0, MAKELPARAM(50, 10)); + todo_wine ok(g_link_id == 0, "Got unexpected link id %d.\n", g_link_id); + + /* test link2 at (25, 25) */ + g_link_id = 0; + SendMessageA(hwnd, WM_LBUTTONDOWN, 1, MAKELPARAM(25, 25)); + SendMessageA(hwnd, WM_LBUTTONUP, 0, MAKELPARAM(25, 25)); + todo_wine ok(g_link_id == 1, "Got unexpected link id %d.\n", g_link_id); + + DestroyWindow(hwnd); +} + START_TEST(syslink) { ULONG_PTR ctx_cookie; @@ -266,6 +303,7 @@ START_TEST(syslink) test_create_syslink(); test_LM_GETIDEALHEIGHT(); test_LM_GETIDEALSIZE(); + test_link_id();
DestroyWindow(hWndParent); unload_v6_module(ctx_cookie, hCtx);
From: Zhaoyi zhaoyi@uniontech.com
Signed-off-by: Zhaoyi zhaoyi@uniontech.com --- dlls/comctl32/syslink.c | 14 ++++++++------ dlls/comctl32/tests/syslink.c | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/dlls/comctl32/syslink.c b/dlls/comctl32/syslink.c index 8130bf19641..6af516ea1e6 100644 --- a/dlls/comctl32/syslink.c +++ b/dlls/comctl32/syslink.c @@ -1320,16 +1320,18 @@ static PDOC_ITEM SYSLINK_LinkAtPt (const SYSLINK_INFO *infoPtr, const POINT *pt,
LIST_FOR_EACH_ENTRY(Current, &infoPtr->Items, DOC_ITEM, entry) { - if((Current->Type == slLink) && SYSLINK_PtInDocItem(Current, *pt) && - (!MustBeEnabled || (Current->u.Link.state & LIS_ENABLED))) + if(Current->Type == slLink) { - if(LinkId != NULL) + if(SYSLINK_PtInDocItem(Current, *pt) && (!MustBeEnabled || (Current->u.Link.state & LIS_ENABLED))) { - *LinkId = id; + if(LinkId != NULL) + { + *LinkId = id; + } + return Current; } - return Current; + id++; } - id++; }
return NULL; diff --git a/dlls/comctl32/tests/syslink.c b/dlls/comctl32/tests/syslink.c index c0bdfdaf0b9..f6c31d92981 100644 --- a/dlls/comctl32/tests/syslink.c +++ b/dlls/comctl32/tests/syslink.c @@ -264,13 +264,13 @@ static void test_link_id(void) g_link_id = 0; SendMessageA(hwnd, WM_LBUTTONDOWN, 1, MAKELPARAM(50, 10)); SendMessageA(hwnd, WM_LBUTTONUP, 0, MAKELPARAM(50, 10)); - todo_wine ok(g_link_id == 0, "Got unexpected link id %d.\n", g_link_id); + ok(g_link_id == 0, "Got unexpected link id %d.\n", g_link_id);
/* test link2 at (25, 25) */ g_link_id = 0; SendMessageA(hwnd, WM_LBUTTONDOWN, 1, MAKELPARAM(25, 25)); SendMessageA(hwnd, WM_LBUTTONUP, 0, MAKELPARAM(25, 25)); - todo_wine ok(g_link_id == 1, "Got unexpected link id %d.\n", g_link_id); + ok(g_link_id == 1, "Got unexpected link id %d.\n", g_link_id);
DestroyWindow(hwnd); }
On Wed Jul 12 01:37:37 2023 +0000, Zhao Yi wrote:
changed this line in [version 12 of the diff](/wine/wine/-/merge_requests/3114/diffs?diff_id=56969&start_sha=95845a0ce0fc7442c8d5923252e56cf26fd1a9ff#9a9442fb2f870d2a427ba92f8beaa96625367933_266_265)
I just made the changes, please review again.
This merge request was approved by Zhiyi Zhang.
@nsivov Hi Nikolay,
Please review my code,thank you.
I'm going to trust @zhiyi zhyi on this one, tests work for me.
This merge request was approved by Nikolay Sivov.