Rebase against 86864486be64a277f6edf8e66709cd0f17a4eed9

This commit is contained in:
Alistair Leslie-Hughes 2018-06-29 08:35:27 +10:00
parent 4e57013325
commit 729a9ebadd
9 changed files with 1 additions and 657 deletions

View File

@ -52,7 +52,7 @@ usage()
# Get the upstream commit sha
upstream_commit()
{
echo "6a04cf4a69205ddf6827fb2a4b97862fd1947c62"
echo "86864486be64a277f6edf8e66709cd0f17a4eed9"
}
# Show version information
@ -338,8 +338,6 @@ patch_enable_all ()
enable_user32_Refresh_MDI_Menus="$1"
enable_user32_ScrollWindowEx="$1"
enable_user32_ShowWindow="$1"
enable_user32_Sorted_Listbox="$1"
enable_user32_WM_MEASUREITEM="$1"
enable_user32_lpCreateParams="$1"
enable_uxtheme_CloseThemeClass="$1"
enable_uxtheme_GTK_Theming="$1"
@ -1193,12 +1191,6 @@ patch_enable ()
user32-ShowWindow)
enable_user32_ShowWindow="$2"
;;
user32-Sorted_Listbox)
enable_user32_Sorted_Listbox="$2"
;;
user32-WM_MEASUREITEM)
enable_user32_WM_MEASUREITEM="$2"
;;
user32-lpCreateParams)
enable_user32_lpCreateParams="$2"
;;
@ -1938,13 +1930,6 @@ if test "$enable_uxtheme_GTK_Theming" -eq 1; then
enable_ntdll_DllRedirects=1
fi
if test "$enable_user32_Sorted_Listbox" -eq 1; then
if test "$enable_user32_WM_MEASUREITEM" -gt 1; then
abort "Patchset user32-WM_MEASUREITEM disabled, but user32-Sorted_Listbox depends on that."
fi
enable_user32_WM_MEASUREITEM=1
fi
if test "$enable_user32_MessageBox_WS_EX_TOPMOST" -eq 1; then
if test "$enable_user32_lpCreateParams" -gt 1; then
abort "Patchset user32-lpCreateParams disabled, but user32-MessageBox_WS_EX_TOPMOST depends on that."
@ -7015,44 +7000,6 @@ if test "$enable_user32_ShowWindow" -eq 1; then
) >> "$patchlist"
fi
# Patchset user32-WM_MEASUREITEM
# |
# | Modified files:
# | * dlls/user32/tests/msg.c
# |
if test "$enable_user32_WM_MEASUREITEM" -eq 1; then
patch_apply user32-WM_MEASUREITEM/0001-user32-tests-Add-a-test-for-WM_MEASUREITEM-when-inse.patch
(
printf '%s\n' '+ { "Dmitry Timoshkov", "user32/tests: Add a test for WM_MEASUREITEM when inserting an item to an owner-drawn listbox.", 2 },';
) >> "$patchlist"
fi
# Patchset user32-Sorted_Listbox
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * user32-WM_MEASUREITEM
# |
# | This patchset fixes the following Wine bugs:
# | * [#42602] Multiple fixes for owner-drawn and sorted listbox
# |
# | Modified files:
# | * dlls/user32/listbox.c, dlls/user32/tests/msg.c
# |
if test "$enable_user32_Sorted_Listbox" -eq 1; then
patch_apply user32-Sorted_Listbox/0001-user32-tests-Add-a-message-test-for-an-owner-drawn-s.patch
patch_apply user32-Sorted_Listbox/0002-user32-tests-Add-some-message-tests-for-not-an-owner.patch
patch_apply user32-Sorted_Listbox/0003-user32-Fix-order-of-items-passed-in-WM_COMPAREITEM-d.patch
patch_apply user32-Sorted_Listbox/0004-user32-Fix-the-listbox-sorting-algorithm.patch
patch_apply user32-Sorted_Listbox/0005-user32-For-an-owner-drawn-listbox-without-strings-WM.patch
(
printf '%s\n' '+ { "Dmitry Timoshkov", "user32/tests: Add a message test for an owner-drawn sorted listbox.", 1 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "user32/tests: Add some message tests for not an owner-drawn listbox.", 1 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "user32: Fix order of items passed in WM_COMPAREITEM data.", 2 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "user32: Fix the listbox sorting algorithm.", 1 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "user32: For an owner-drawn listbox without strings WM_MEASUREITEM still needs correct itemData.", 1 },';
) >> "$patchlist"
fi
# Patchset uxtheme-CloseThemeClass
# |
# | This patchset fixes the following Wine bugs:

View File

@ -1,160 +0,0 @@
From 726802175f5249d2313620f488a55ffa391c56ce Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Wed, 8 Mar 2017 16:33:41 +0800
Subject: user32/tests: Add a message test for an owner-drawn sorted listbox.
---
dlls/user32/tests/msg.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 88 insertions(+), 3 deletions(-)
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c
index a742f670ab..3a492b37bd 100644
--- a/dlls/user32/tests/msg.c
+++ b/dlls/user32/tests/msg.c
@@ -2232,18 +2232,61 @@ static void add_message_(int line, const struct recvd_message *msg)
{
MEASURE_ITEM_STRUCT mi;
MEASUREITEMSTRUCT *mis = (MEASUREITEMSTRUCT *)msg->lParam;
+ BOOL is_unicode_data = TRUE;
sprintf( seq->output, "%s: %p WM_MEASUREITEM: CtlType %#x, CtlID %#x, itemID %#x, itemData %#lx",
msg->descr, msg->hwnd, mis->CtlType, mis->CtlID,
mis->itemID, mis->itemData);
+ if (mis->CtlType == ODT_LISTBOX)
+ {
+ HWND ctrl = GetDlgItem(msg->hwnd, mis->CtlID);
+ is_unicode_data = GetWindowLongA(ctrl, GWL_STYLE) & LBS_HASSTRINGS;
+ }
+
mi.u.wp = 0;
mi.u.item.CtlType = mis->CtlType;
mi.u.item.CtlID = mis->CtlID;
mi.u.item.itemID = mis->itemID;
mi.u.item.wParam = msg->wParam;
seq->wParam = mi.u.wp;
- seq->lParam = mis->itemData ? hash_Ly_W((const WCHAR *)mis->itemData) : 0;
+ if (is_unicode_data)
+ seq->lParam = mis->itemData ? hash_Ly_W((const WCHAR *)mis->itemData) : 0;
+ else
+ seq->lParam = mis->itemData ? hash_Ly((const char *)mis->itemData) : 0;
+ break;
+ }
+
+ case WM_COMPAREITEM:
+ {
+ COMPAREITEMSTRUCT *cis = (COMPAREITEMSTRUCT *)msg->lParam;
+ HWND ctrl = GetDlgItem(msg->hwnd, cis->CtlID);
+ BOOL is_unicode_data = TRUE;
+
+ ok(msg->wParam == cis->CtlID, "expected %#x, got %#lx\n", cis->CtlID, msg->wParam);
+ ok(cis->hwndItem == ctrl, "expected %p, got %p\n", ctrl, cis->hwndItem);
+todo_wine
+ ok((int)cis->itemID1 >= 0, "expected >= 0, got %d\n", cis->itemID1);
+todo_wine
+ ok((int)cis->itemID2 == -1, "expected -1, got %d\n", cis->itemID2);
+
+ sprintf( seq->output, "%s: %p WM_COMPAREITEM: CtlType %#x, CtlID %#x, itemID1 %#x, itemData1 %#lx, itemID2 %#x, itemData2 %#lx",
+ msg->descr, msg->hwnd, cis->CtlType, cis->CtlID,
+ cis->itemID1, cis->itemData1, cis->itemID2, cis->itemData2);
+
+ if (cis->CtlType == ODT_LISTBOX)
+ is_unicode_data = GetWindowLongA(ctrl, GWL_STYLE) & LBS_HASSTRINGS;
+
+ if (is_unicode_data)
+ {
+ seq->wParam = cis->itemData1 ? hash_Ly_W((const WCHAR *)cis->itemData1) : 0;
+ seq->lParam = cis->itemData2 ? hash_Ly_W((const WCHAR *)cis->itemData2) : 0;
+ }
+ else
+ {
+ seq->wParam = cis->itemData1 ? hash_Ly((const char *)cis->itemData1) : 0;
+ seq->lParam = cis->itemData2 ? hash_Ly((const char *)cis->itemData2) : 0;
+ }
break;
}
@@ -9261,7 +9304,7 @@ static LRESULT WINAPI ParentMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam
message == WM_PARENTNOTIFY || message == WM_CANCELMODE ||
message == WM_SETFOCUS || message == WM_KILLFOCUS ||
message == WM_ENABLE || message == WM_ENTERIDLE ||
- message == WM_DRAWITEM || message == WM_MEASUREITEM ||
+ message == WM_DRAWITEM || message == WM_MEASUREITEM || message == WM_COMPAREITEM ||
message == WM_COMMAND || message == WM_IME_SETCONTEXT)
{
switch (message)
@@ -9309,7 +9352,7 @@ static LRESULT WINAPI ParentMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam
ret = DefWindowProcA(hwnd, message, wParam, lParam);
defwndproc_counter--;
- return ret;
+ return message == WM_COMPAREITEM ? -1 : ret;
}
static INT_PTR CALLBACK StopQuitMsgCheckProcA(HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
@@ -14430,6 +14473,19 @@ static const struct message wm_lb_addstring[] =
{ WM_MEASUREITEM, sent|wparam|lparam|parent, 0xf2f2, 0xf30604ef },
{ 0 }
};
+static const struct message wm_lb_addstring_sort[] =
+{
+ { LB_ADDSTRING, sent|wparam|lparam, 0, 0xf30604ed },
+ { WM_MEASUREITEM, sent|wparam|lparam|parent, 0xf0f2, 0xf30604ed },
+ { LB_ADDSTRING, sent|wparam|lparam, 0, 0xf30604ee },
+ { WM_COMPAREITEM, sent|wparam|lparam|parent, 0xf30604ed, 0xf30604ee },
+ { WM_MEASUREITEM, sent|wparam|lparam|parent, 0xf1f2, 0xf30604ee },
+ { LB_ADDSTRING, sent|wparam|lparam, 0, 0xf30604ef },
+ { WM_COMPAREITEM, sent|wparam|lparam|parent, 0xf30604ed, 0xf30604ef },
+ { WM_COMPAREITEM, sent|wparam|lparam|parent, 0xf30604ee, 0xf30604ef },
+ { WM_MEASUREITEM, sent|wparam|lparam|parent, 0xf2f2, 0xf30604ef },
+ { 0 }
+};
#define check_lb_state(a1, a2, a3, a4, a5) check_lb_state_dbg(a1, a2, a3, a4, a5, __LINE__)
@@ -14495,6 +14551,7 @@ static void test_listbox_messages(void)
parent = CreateWindowExA(0, "TestParentClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
100, 100, 200, 200, 0, 0, 0, NULL);
+ /* with LBS_HASSTRINGS */
listbox = CreateWindowExA(WS_EX_NOPARENTNOTIFY, "ListBox", NULL,
WS_CHILD | LBS_NOTIFY | LBS_OWNERDRAWVARIABLE | LBS_HASSTRINGS | WS_VISIBLE,
10, 10, 80, 80, parent, (HMENU)ID_LISTBOX, 0, NULL);
@@ -14576,6 +14633,34 @@ static void test_listbox_messages(void)
log_all_parent_messages--;
DestroyWindow(listbox);
+
+ /* with LBS_SORT and without LBS_HASSTRINGS */
+ listbox = CreateWindowExA(WS_EX_NOPARENTNOTIFY, "ListBox", NULL,
+ WS_CHILD | LBS_NOTIFY | LBS_OWNERDRAWVARIABLE | LBS_SORT | WS_VISIBLE,
+ 10, 10, 80, 80, parent, (HMENU)ID_LISTBOX, 0, NULL);
+ listbox_orig_proc = (WNDPROC)SetWindowLongPtrA(listbox, GWLP_WNDPROC, (ULONG_PTR)listbox_hook_proc);
+
+ check_lb_state(listbox, 0, LB_ERR, 0, 0);
+
+ flush_sequence();
+
+ log_all_parent_messages++;
+
+ ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 0");
+ ok(ret == 0, "expected 0, got %ld\n", ret);
+ ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 1");
+todo_wine
+ ok(ret == 1, "expected 1, got %ld\n", ret);
+ ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 2");
+todo_wine
+ ok(ret == 2, "expected 2, got %ld\n", ret);
+
+ ok_sequence(wm_lb_addstring_sort, "LB_ADDSTRING", TRUE);
+ check_lb_state(listbox, 3, LB_ERR, 0, 0);
+
+ log_all_parent_messages--;
+
+ DestroyWindow(listbox);
DestroyWindow(parent);
}
--
2.11.0

View File

@ -1,124 +0,0 @@
From e61138a34cb8fb869ceb1c6427dbe3cfb708ec03 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Wed, 16 Aug 2017 12:58:24 +0800
Subject: user32/tests: Add some message tests for not an owner-drawn listbox.
---
dlls/user32/tests/msg.c | 69 +++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 64 insertions(+), 5 deletions(-)
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c
index 383f8e22299..5054599611d 100644
--- a/dlls/user32/tests/msg.c
+++ b/dlls/user32/tests/msg.c
@@ -14484,6 +14484,13 @@ static const struct message wm_lb_deletestring_reset[] =
};
static const struct message wm_lb_addstring[] =
{
+ { LB_ADDSTRING, sent|wparam|lparam, 0, 0xf30604ef },
+ { LB_ADDSTRING, sent|wparam|lparam, 0, 0xf30604ed },
+ { LB_ADDSTRING, sent|wparam|lparam, 0, 0xf30604ee },
+ { 0 }
+};
+static const struct message wm_lb_addstring_ownerdraw[] =
+{
{ LB_ADDSTRING, sent|wparam|lparam, 0, 0xf30604ed },
{ WM_MEASUREITEM, sent|wparam|lparam|parent, 0xf0f2, 0xf30604ed },
{ LB_ADDSTRING, sent|wparam|lparam, 0, 0xf30604ee },
@@ -14492,7 +14499,7 @@ static const struct message wm_lb_addstring[] =
{ WM_MEASUREITEM, sent|wparam|lparam|parent, 0xf2f2, 0xf30604ef },
{ 0 }
};
-static const struct message wm_lb_addstring_sort[] =
+static const struct message wm_lb_addstring_sort_ownerdraw[] =
{
{ LB_ADDSTRING, sent|wparam|lparam, 0, 0xf30604ed },
{ WM_MEASUREITEM, sent|wparam|lparam|parent, 0xf0f2, 0xf30604ed },
@@ -14580,6 +14587,8 @@ static void test_listbox_messages(void)
flush_sequence();
+ log_all_parent_messages++;
+
ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 0");
ok(ret == 0, "expected 0, got %ld\n", ret);
ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 1");
@@ -14587,13 +14596,11 @@ static void test_listbox_messages(void)
ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 2");
ok(ret == 2, "expected 2, got %ld\n", ret);
- ok_sequence(wm_lb_addstring, "LB_ADDSTRING", FALSE);
+ ok_sequence(wm_lb_addstring_ownerdraw, "LB_ADDSTRING", FALSE);
check_lb_state(listbox, 3, LB_ERR, 0, 0);
flush_sequence();
- log_all_parent_messages++;
-
trace("selecting item 0\n");
ret = SendMessageA(listbox, LB_SETCURSEL, 0, 0);
ok(ret == 0, "expected 0, got %ld\n", ret);
@@ -14674,7 +14681,59 @@ todo_wine
todo_wine
ok(ret == 2, "expected 2, got %ld\n", ret);
- ok_sequence(wm_lb_addstring_sort, "LB_ADDSTRING", TRUE);
+ ok_sequence(wm_lb_addstring_sort_ownerdraw, "LB_ADDSTRING", TRUE);
+ check_lb_state(listbox, 3, LB_ERR, 0, 0);
+
+ log_all_parent_messages--;
+
+ DestroyWindow(listbox);
+
+ /* with LBS_HASSTRINGS */
+ listbox = CreateWindowExA(WS_EX_NOPARENTNOTIFY, "ListBox", NULL,
+ WS_CHILD | LBS_NOTIFY | LBS_HASSTRINGS | WS_VISIBLE,
+ 10, 10, 80, 80, parent, (HMENU)ID_LISTBOX, 0, NULL);
+ listbox_orig_proc = (WNDPROC)SetWindowLongPtrA(listbox, GWLP_WNDPROC, (ULONG_PTR)listbox_hook_proc);
+
+ check_lb_state(listbox, 0, LB_ERR, 0, 0);
+
+ flush_sequence();
+
+ log_all_parent_messages++;
+
+ ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 2");
+ ok(ret == 0, "expected 0, got %ld\n", ret);
+ ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 0");
+ ok(ret == 1, "expected 1, got %ld\n", ret);
+ ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 1");
+ ok(ret == 2, "expected 2, got %ld\n", ret);
+
+ ok_sequence(wm_lb_addstring, "LB_ADDSTRING", FALSE);
+ check_lb_state(listbox, 3, LB_ERR, 0, 0);
+
+ log_all_parent_messages--;
+
+ DestroyWindow(listbox);
+
+ /* with LBS_HASSTRINGS and LBS_SORT */
+ listbox = CreateWindowExA(WS_EX_NOPARENTNOTIFY, "ListBox", NULL,
+ WS_CHILD | LBS_NOTIFY | LBS_HASSTRINGS | LBS_SORT | WS_VISIBLE,
+ 10, 10, 80, 80, parent, (HMENU)ID_LISTBOX, 0, NULL);
+ listbox_orig_proc = (WNDPROC)SetWindowLongPtrA(listbox, GWLP_WNDPROC, (ULONG_PTR)listbox_hook_proc);
+
+ check_lb_state(listbox, 0, LB_ERR, 0, 0);
+
+ flush_sequence();
+
+ log_all_parent_messages++;
+
+ ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 2");
+ ok(ret == 0, "expected 0, got %ld\n", ret);
+ ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 0");
+ ok(ret == 0, "expected 0, got %ld\n", ret);
+ ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 1");
+ ok(ret == 1, "expected 1, got %ld\n", ret);
+
+ ok_sequence(wm_lb_addstring, "LB_ADDSTRING", FALSE);
check_lb_state(listbox, 3, LB_ERR, 0, 0);
log_all_parent_messages--;
--
2.13.1

View File

@ -1,72 +0,0 @@
From 8e2e80724c647b878bfa464fc8a0e6495d714a92 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Wed, 8 Mar 2017 16:48:26 +0800
Subject: user32: Fix order of items passed in WM_COMPAREITEM data. (v2)
---
dlls/user32/listbox.c | 12 ++++++------
dlls/user32/tests/msg.c | 4 ----
2 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/dlls/user32/listbox.c b/dlls/user32/listbox.c
index 0b3225b09e0..75257a92a67 100644
--- a/dlls/user32/listbox.c
+++ b/dlls/user32/listbox.c
@@ -847,7 +847,7 @@ static INT LISTBOX_FindStringPos( LB_DESCR *descr, LPCWSTR str, BOOL exact )
{
index = (min + max) / 2;
if (HAS_STRINGS(descr))
- res = LISTBOX_lstrcmpiW( descr->locale, str, descr->items[index].str);
+ res = LISTBOX_lstrcmpiW( descr->locale, descr->items[index].str, str );
else
{
COMPAREITEMSTRUCT cis;
@@ -858,15 +858,15 @@ static INT LISTBOX_FindStringPos( LB_DESCR *descr, LPCWSTR str, BOOL exact )
cis.hwndItem = descr->self;
/* note that some application (MetaStock) expects the second item
* to be in the listbox */
- cis.itemID1 = -1;
- cis.itemData1 = (ULONG_PTR)str;
- cis.itemID2 = index;
- cis.itemData2 = descr->items[index].data;
+ cis.itemID1 = index;
+ cis.itemData1 = descr->items[index].data;
+ cis.itemID2 = -1;
+ cis.itemData2 = (ULONG_PTR)str;
cis.dwLocaleId = descr->locale;
res = SendMessageW( descr->owner, WM_COMPAREITEM, id, (LPARAM)&cis );
}
if (!res) return index;
- if (res < 0) max = index;
+ if (res > 0) max = index;
else min = index + 1;
}
return exact ? -1 : max;
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c
index 7a7ee74c983..88137c45fe2 100644
--- a/dlls/user32/tests/msg.c
+++ b/dlls/user32/tests/msg.c
@@ -2278,9 +2278,7 @@ static void add_message_(int line, const struct recvd_message *msg)
ok(msg->wParam == cis->CtlID, "expected %#x, got %#lx\n", cis->CtlID, msg->wParam);
ok(cis->hwndItem == ctrl, "expected %p, got %p\n", ctrl, cis->hwndItem);
-todo_wine
ok((int)cis->itemID1 >= 0, "expected >= 0, got %d\n", cis->itemID1);
-todo_wine
ok((int)cis->itemID2 == -1, "expected -1, got %d\n", cis->itemID2);
sprintf( seq->output, "%s: %p WM_COMPAREITEM: CtlType %#x, CtlID %#x, itemID1 %#x, itemData1 %#lx, itemID2 %#x, itemData2 %#lx",
@@ -14682,10 +14680,8 @@ static void test_listbox_messages(void)
ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 0");
ok(ret == 0, "expected 0, got %ld\n", ret);
ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 1");
-todo_wine
ok(ret == 1, "expected 1, got %ld\n", ret);
ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 2");
-todo_wine
ok(ret == 2, "expected 2, got %ld\n", ret);
ok_sequence(wm_lb_addstring_sort_ownerdraw, "LB_ADDSTRING", TRUE);
--
2.13.1

View File

@ -1,44 +0,0 @@
From 29128bbe18f85edc8f7760262c6b598bd789ffb0 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Wed, 8 Mar 2017 17:48:58 +0800
Subject: user32: Fix the listbox sorting algorithm.
---
dlls/user32/listbox.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/dlls/user32/listbox.c b/dlls/user32/listbox.c
index 4269ef0717..5eb266b15a 100644
--- a/dlls/user32/listbox.c
+++ b/dlls/user32/listbox.c
@@ -840,10 +840,11 @@ static INT LISTBOX_FindStringPos( LB_DESCR *descr, LPCWSTR str, BOOL exact )
{
INT index, min, max, res;
- if (!(descr->style & LBS_SORT)) return -1; /* Add it at the end */
+ if (!descr->nb_items || !(descr->style & LBS_SORT)) return -1; /* Add it at the end */
+
min = 0;
- max = descr->nb_items;
- while (min != max)
+ max = descr->nb_items - 1;
+ while (min <= max)
{
index = (min + max) / 2;
if (HAS_STRINGS(descr))
@@ -866,10 +867,10 @@ static INT LISTBOX_FindStringPos( LB_DESCR *descr, LPCWSTR str, BOOL exact )
res = SendMessageW( descr->owner, WM_COMPAREITEM, id, (LPARAM)&cis );
}
if (!res) return index;
- if (res > 0) max = index;
+ if (res > 0) max = index - 1;
else min = index + 1;
}
- return exact ? -1 : max;
+ return exact ? -1 : min;
}
--
2.11.0

View File

@ -1,40 +0,0 @@
From f3f3100efb0b3e702957b89cc0bfc58040b1a1a7 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Wed, 8 Mar 2017 17:52:10 +0800
Subject: user32: For an owner-drawn listbox without strings WM_MEASUREITEM
still needs correct itemData.
---
dlls/user32/listbox.c | 2 +-
dlls/user32/tests/msg.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/user32/listbox.c b/dlls/user32/listbox.c
index 9caccf6..af8ee40 100644
--- a/dlls/user32/listbox.c
+++ b/dlls/user32/listbox.c
@@ -1554,7 +1554,7 @@ static LRESULT LISTBOX_InsertItem( LB_DESCR *descr, INT index,
mis.CtlType = ODT_LISTBOX;
mis.CtlID = id;
mis.itemID = index;
- mis.itemData = data;
+ mis.itemData = str ? (ULONG_PTR)str : data;
mis.itemHeight = descr->item_height;
SendMessageW( descr->owner, WM_MEASUREITEM, id, (LPARAM)&mis );
item->height = mis.itemHeight ? mis.itemHeight : 1;
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c
index f532f1c..65712a7 100644
--- a/dlls/user32/tests/msg.c
+++ b/dlls/user32/tests/msg.c
@@ -14272,7 +14272,7 @@ static void test_listbox_messages(void)
ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 2");
ok(ret == 2, "expected 2, got %ld\n", ret);
- ok_sequence(wm_lb_addstring_sort_ownerdraw, "LB_ADDSTRING", TRUE);
+ ok_sequence(wm_lb_addstring_sort_ownerdraw, "LB_ADDSTRING", FALSE);
check_lb_state(listbox, 3, LB_ERR, 0, 0);
log_all_parent_messages--;
--
2.7.4

View File

@ -1,2 +0,0 @@
Fixes: [42602] Multiple fixes for owner-drawn and sorted listbox
Depends: user32-WM_MEASUREITEM

View File

@ -1,159 +0,0 @@
From 1c43865f5fc1ef1ab71572773e560821d4b4a753 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Sun, 12 Jun 2016 16:16:48 +0800
Subject: user32/tests: Add a test for WM_MEASUREITEM when inserting an item to
an owner-drawn listbox (v2).
---
dlls/user32/tests/msg.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 75 insertions(+), 4 deletions(-)
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c
index 36d1e33..c46b8e1 100644
--- a/dlls/user32/tests/msg.c
+++ b/dlls/user32/tests/msg.c
@@ -3,7 +3,7 @@
*
* Copyright 1999 Ove Kaaven
* Copyright 2003 Dimitrie O. Paun
- * Copyright 2004, 2005 Dmitry Timoshkov
+ * Copyright 2004,2005,2016 Dmitry Timoshkov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -98,6 +98,22 @@ typedef struct
} u;
} DRAW_ITEM_STRUCT;
+/* encoded MEASUREITEMSTRUCT into a WPARAM */
+typedef struct
+{
+ union
+ {
+ struct
+ {
+ UINT CtlType : 4;
+ UINT CtlID : 4;
+ UINT itemID : 4;
+ UINT wParam : 20;
+ } item;
+ WPARAM wp;
+ } u;
+} MEASURE_ITEM_STRUCT;
+
static BOOL test_DestroyWindow_flag;
static HWINEVENTHOOK hEvent_hook;
static HHOOK hKBD_hook;
@@ -2099,6 +2115,25 @@ static BOOL ignore_message( UINT message )
message == WM_DWMNCRENDERINGCHANGED);
}
+static unsigned hash_Ly_W(const WCHAR *str)
+{
+ unsigned hash = 0;
+
+ for (; *str; str++)
+ hash = hash * 1664525u + (unsigned char)(*str) + 1013904223u;
+
+ return hash;
+}
+
+static unsigned hash_Ly(const char *str)
+{
+ unsigned hash = 0;
+
+ for (; *str; str++)
+ hash = hash * 1664525u + (unsigned char)(*str) + 1013904223u;
+
+ return hash;
+}
#define add_message(msg) add_message_(__LINE__,msg);
static void add_message_(int line, const struct recvd_message *msg)
@@ -2203,6 +2238,26 @@ static void add_message_(int line, const struct recvd_message *msg)
seq->lParam = di.u.lp;
break;
}
+
+ case WM_MEASUREITEM:
+ {
+ MEASURE_ITEM_STRUCT mi;
+ MEASUREITEMSTRUCT *mis = (MEASUREITEMSTRUCT *)msg->lParam;
+
+ sprintf( seq->output, "%s: %p WM_MEASUREITEM: CtlType %#x, CtlID %#x, itemID %#x, itemData %#lx",
+ msg->descr, msg->hwnd, mis->CtlType, mis->CtlID,
+ mis->itemID, mis->itemData);
+
+ mi.u.wp = 0;
+ mi.u.item.CtlType = mis->CtlType;
+ mi.u.item.CtlID = mis->CtlID;
+ mi.u.item.itemID = mis->itemID;
+ mi.u.item.wParam = msg->wParam;
+ seq->wParam = mi.u.wp;
+ seq->lParam = mis->itemData ? hash_Ly_W((const WCHAR *)mis->itemData) : 0;
+ break;
+ }
+
default:
if (msg->message >= 0xc000) return; /* ignore registered messages */
sprintf( seq->output, "%s: %p %04x wp %08lx lp %08lx",
@@ -8874,8 +8929,8 @@ static LRESULT WINAPI ParentMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam
message == WM_PARENTNOTIFY || message == WM_CANCELMODE ||
message == WM_SETFOCUS || message == WM_KILLFOCUS ||
message == WM_ENABLE || message == WM_ENTERIDLE ||
- message == WM_DRAWITEM || message == WM_COMMAND ||
- message == WM_IME_SETCONTEXT)
+ message == WM_DRAWITEM || message == WM_MEASUREITEM ||
+ message == WM_COMMAND || message == WM_IME_SETCONTEXT)
{
switch (message)
{
@@ -13979,6 +14034,16 @@ static const struct message wm_lb_deletestring_reset[] =
{ WM_DRAWITEM, sent|wparam|parent|optional, ID_LISTBOX },
{ 0 }
};
+static const struct message wm_lb_addstring[] =
+{
+ { LB_ADDSTRING, sent|wparam|lparam, 0, 0xf30604ed },
+ { WM_MEASUREITEM, sent|wparam|lparam|parent, 0xf0f2, 0xf30604ed },
+ { LB_ADDSTRING, sent|wparam|lparam, 0, 0xf30604ee },
+ { WM_MEASUREITEM, sent|wparam|lparam|parent, 0xf1f2, 0xf30604ee },
+ { LB_ADDSTRING, sent|wparam|lparam, 0, 0xf30604ef },
+ { WM_MEASUREITEM, sent|wparam|lparam|parent, 0xf2f2, 0xf30604ef },
+ { 0 }
+};
#define check_lb_state(a1, a2, a3, a4, a5) check_lb_state_dbg(a1, a2, a3, a4, a5, __LINE__)
@@ -14004,7 +14069,10 @@ static LRESULT WINAPI listbox_hook_proc(HWND hwnd, UINT message, WPARAM wp, LPAR
msg.flags = sent|wparam|lparam;
if (defwndproc_counter) msg.flags |= defwinproc;
msg.wParam = wp;
- msg.lParam = lp;
+ if (message == LB_ADDSTRING)
+ msg.lParam = lp ? hash_Ly((const char *)lp) : 0;
+ else
+ msg.lParam = lp;
msg.descr = "listbox";
add_message(&msg);
}
@@ -14048,6 +14116,8 @@ static void test_listbox_messages(void)
check_lb_state(listbox, 0, LB_ERR, 0, 0);
+ flush_sequence();
+
ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 0");
ok(ret == 0, "expected 0, got %ld\n", ret);
ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 1");
@@ -14055,6 +14125,7 @@ static void test_listbox_messages(void)
ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 2");
ok(ret == 2, "expected 2, got %ld\n", ret);
+ ok_sequence(wm_lb_addstring, "LB_ADDSTRING", FALSE);
check_lb_state(listbox, 3, LB_ERR, 0, 0);
flush_sequence();
--
2.7.4

View File

@ -1,2 +0,0 @@
Fixes: Pass correct itemData to WM_MEASUREITEM when inserting an item to an owner-drawn listbox
# Originally fixed 37025, now only tests left.