Module: wine Branch: master Commit: e5afb283cf11ec81c4022bc69c22b4765064f0e5 URL: https://gitlab.winehq.org/wine/wine/-/commit/e5afb283cf11ec81c4022bc69c22b47...
Author: Zebediah Figura zfigura@codeweavers.com Date: Tue Mar 5 21:31:03 2024 -0600
shell32: Respect the drop effect in do_paste().
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=34322
---
dlls/shell32/shlview_cmenu.c | 17 ++++++++++++++++- dlls/shell32/tests/shlfolder.c | 22 +++------------------- 2 files changed, 19 insertions(+), 20 deletions(-)
diff --git a/dlls/shell32/shlview_cmenu.c b/dlls/shell32/shlview_cmenu.c index 7fee1c1c2df..cac33c39af7 100644 --- a/dlls/shell32/shlview_cmenu.c +++ b/dlls/shell32/shlview_cmenu.c @@ -409,6 +409,7 @@ static WCHAR *build_source_paths(ITEMIDLIST *root_pidl, ITEMIDLIST **pidls, unsi static HRESULT do_paste(ContextMenu *menu, HWND hwnd) { IPersistFolder2 *dst_persist; + const DWORD *drop_effect; IShellFolder *dst_folder; WCHAR dst_path[MAX_PATH]; SHFILEOPSTRUCTW op = {0}; @@ -456,13 +457,27 @@ static HRESULT do_paste(ContextMenu *menu, HWND hwnd) ILFree(dst_pidl);
op.hwnd = hwnd; - op.wFunc = FO_COPY; op.pTo = dst_path; op.fFlags = FOF_ALLOWUNDO;
if (FAILED(hr = OleGetClipboard(&data))) return hr;
+ if (FAILED(hr = get_data_format(data, RegisterClipboardFormatW(CFSTR_PREFERREDDROPEFFECTW), &medium))) + { + ERR("Failed to get drop effect.\n"); + IDataObject_Release(data); + return hr; + } + drop_effect = GlobalLock(medium.hGlobal); + if (*drop_effect & DROPEFFECT_COPY) + op.wFunc = FO_COPY; + else if (*drop_effect & DROPEFFECT_MOVE) + op.wFunc = FO_MOVE; + else + FIXME("Unhandled drop effect %#lx.\n", *drop_effect); + GlobalUnlock(medium.hGlobal); + if (SUCCEEDED(get_data_format(data, RegisterClipboardFormatW(CFSTR_SHELLIDLISTW), &medium))) { const CIDA *cida = GlobalLock(medium.hGlobal); diff --git a/dlls/shell32/tests/shlfolder.c b/dlls/shell32/tests/shlfolder.c index b2448938728..06ccfe2f553 100644 --- a/dlls/shell32/tests/shlfolder.c +++ b/dlls/shell32/tests/shlfolder.c @@ -5890,14 +5890,7 @@ static void test_copy_paste(void)
format.cfFormat = RegisterClipboardFormatW(CFSTR_PREFERREDDROPEFFECTW); hr = IDataObject_GetData(data_obj, &format, &medium); - todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); - if (hr == S_OK) - { - effect = GlobalLock(medium.hGlobal); - ok(*effect == DROPEFFECT_MOVE, "Got effect %#lx.\n", *effect); - GlobalUnlock(medium.hGlobal); - ReleaseStgMedium(&medium); - } + ok(hr == S_OK, "Got hr %#lx.\n", hr);
IDataObject_Release(data_obj);
@@ -5913,9 +5906,7 @@ static void test_copy_paste(void) ok(hr == S_OK, "Got hr %#lx.\n", hr);
ret = MoveFileExW(L"testcopy_dst/testcopy_src", L"testcopy_src", 0); - todo_wine ok(ret, "Got error %lu.\n", GetLastError()); - if (!ret && GetLastError() == ERROR_ALREADY_EXISTS) - RemoveDirectoryW(L"testcopy_dst/testcopy_src"); + ok(ret, "Got error %lu.\n", GetLastError());
/* Copy. */
@@ -5933,14 +5924,7 @@ static void test_copy_paste(void)
format.cfFormat = RegisterClipboardFormatW(CFSTR_PREFERREDDROPEFFECTW); hr = IDataObject_GetData(data_obj, &format, &medium); - todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); - if (hr == S_OK) - { - effect = GlobalLock(medium.hGlobal); - ok(*effect == (DROPEFFECT_COPY | DROPEFFECT_LINK), "Got effect %#lx.\n", *effect); - GlobalUnlock(medium.hGlobal); - ReleaseStgMedium(&medium); - } + ok(hr == S_OK, "Got hr %#lx.\n", hr);
IDataObject_Release(data_obj);