Rebase against c1b8db0c28ac5b7a14567bfb6df2c0af364de6a2.

This commit is contained in:
Zebediah Figura
2024-03-04 16:41:59 -06:00
parent 21b92f9611
commit ff5fc9c0fa
8 changed files with 2 additions and 365 deletions

View File

@@ -1,128 +0,0 @@
From cb562a6cf3aefe59d6173838e03030d0d882cf75 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sat, 2 Apr 2016 01:39:40 +0200
Subject: [PATCH] shell32: Implement insert/paste for item context menus.
---
dlls/shell32/shell32.rc | 1 +
dlls/shell32/shlview_cmenu.c | 45 ++++++++++++++++++++++++++++++++----
2 files changed, 41 insertions(+), 5 deletions(-)
diff --git a/dlls/shell32/shell32.rc b/dlls/shell32/shell32.rc
index a50fab6815d..dc418069100 100644
--- a/dlls/shell32/shell32.rc
+++ b/dlls/shell32/shell32.rc
@@ -95,6 +95,7 @@ BEGIN
BEGIN
MENUITEM "C&ut", FCIDM_SHVIEW_CUT
MENUITEM "&Copy", FCIDM_SHVIEW_COPY
+ MENUITEM "&Paste", FCIDM_SHVIEW_INSERT
MENUITEM SEPARATOR
MENUITEM "Create &Link", FCIDM_SHVIEW_CREATELINK
MENUITEM "&Delete", FCIDM_SHVIEW_DELETE
diff --git a/dlls/shell32/shlview_cmenu.c b/dlls/shell32/shlview_cmenu.c
index 9057d7c0175..aaa726ec14a 100644
--- a/dlls/shell32/shlview_cmenu.c
+++ b/dlls/shell32/shlview_cmenu.c
@@ -73,6 +73,8 @@ typedef struct
BOOL desktop;
} ContextMenu;
+static HRESULT DoPaste(ContextMenu *This);
+
static inline ContextMenu *impl_from_IContextMenu3(IContextMenu3 *iface)
{
return CONTAINING_RECORD(iface, ContextMenu, IContextMenu3_iface);
@@ -188,6 +190,30 @@ static UINT max_menu_id(HMENU hmenu, UINT offset, UINT last)
return max_id;
}
+static BOOL CheckClipboard(void)
+{
+ IDataObject *pda;
+ BOOL ret = FALSE;
+
+ if (SUCCEEDED(OleGetClipboard(&pda)))
+ {
+ STGMEDIUM medium;
+ FORMATETC formatetc;
+
+ /* Set the FORMATETC structure*/
+ InitFormatEtc(formatetc, RegisterClipboardFormatW(CFSTR_SHELLIDLISTW), TYMED_HGLOBAL);
+
+ /* Get the pidls from IDataObject */
+ if (SUCCEEDED(IDataObject_GetData(pda, &formatetc, &medium)))
+ {
+ ReleaseStgMedium(&medium);
+ ret = TRUE;
+ }
+ IDataObject_Release(pda);
+ }
+ return ret;
+}
+
static HRESULT WINAPI ItemMenu_QueryContextMenu(
IContextMenu3 *iface,
HMENU hmenu,
@@ -199,6 +225,7 @@ static HRESULT WINAPI ItemMenu_QueryContextMenu(
ContextMenu *This = impl_from_IContextMenu3(iface);
MENUITEMINFOW mi;
INT uIDMax;
+ DWORD attr = SFGAO_CANRENAME;
TRACE("(%p)->(%p %d 0x%x 0x%x 0x%x )\n", This, hmenu, indexMenu, idCmdFirst, idCmdLast, uFlags);
@@ -232,6 +259,9 @@ static HRESULT WINAPI ItemMenu_QueryContextMenu(
SetMenuDefaultItem(hmenu, 0, MF_BYPOSITION);
+ if (This->apidl && This->cidl == 1)
+ IShellFolder_GetAttributesOf(This->parent, 1, (LPCITEMIDLIST*)This->apidl, &attr);
+
if(uFlags & ~CMF_CANRENAME)
RemoveMenu(hmenu, FCIDM_SHVIEW_RENAME - FCIDM_BASE + idCmdFirst, MF_BYCOMMAND);
else
@@ -242,16 +272,14 @@ static HRESULT WINAPI ItemMenu_QueryContextMenu(
if (!This->apidl || This->cidl > 1)
enable |= MFS_DISABLED;
else
- {
- DWORD attr = SFGAO_CANRENAME;
-
- IShellFolder_GetAttributesOf(This->parent, 1, (LPCITEMIDLIST*)This->apidl, &attr);
enable |= (attr & SFGAO_CANRENAME) ? MFS_ENABLED : MFS_DISABLED;
- }
EnableMenuItem(hmenu, FCIDM_SHVIEW_RENAME - FCIDM_BASE + idCmdFirst, enable);
}
+ if ((attr & (SFGAO_FILESYSTEM|SFGAO_FOLDER)) != (SFGAO_FILESYSTEM|SFGAO_FOLDER) || !CheckClipboard())
+ RemoveMenu(hmenu, FCIDM_SHVIEW_INSERT - FCIDM_BASE + idCmdFirst, MF_BYCOMMAND);
+
return MAKE_HRESULT(SEVERITY_SUCCESS, 0, uIDMax-idCmdFirst);
}
return MAKE_HRESULT(SEVERITY_SUCCESS, 0, 0);
@@ -791,6 +819,10 @@ static HRESULT WINAPI ItemMenu_InvokeCommand(
TRACE("Verb FCIDM_SHVIEW_CUT\n");
DoCopyOrCut(This, lpcmi->hwnd, TRUE);
break;
+ case FCIDM_SHVIEW_INSERT:
+ TRACE("Verb FCIDM_SHVIEW_INSERT\n");
+ DoPaste(This);
+ break;
case FCIDM_SHVIEW_PROPERTIES:
TRACE("Verb FCIDM_SHVIEW_PROPERTIES\n");
DoOpenProperties(This, lpcmi->hwnd);
@@ -845,6 +877,9 @@ static HRESULT WINAPI ItemMenu_GetCommandString(IContextMenu3 *iface, UINT_PTR c
case FCIDM_SHVIEW_COPY:
cmdW = L"copy";
break;
+ case FCIDM_SHVIEW_INSERT:
+ cmdW = L"paste";
+ break;
case FCIDM_SHVIEW_CREATELINK:
cmdW = L"link";
break;
--
2.43.0

View File

@@ -1,30 +0,0 @@
From 295de3efbdb815a703e77c391ee1f3038987495b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sat, 2 Apr 2016 04:41:56 +0200
Subject: [PATCH] shell32: Recognize cut/copy/paste string verbs in item menu
context menu.
---
dlls/shell32/shlview_cmenu.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/dlls/shell32/shlview_cmenu.c b/dlls/shell32/shlview_cmenu.c
index 3dce4a1fbac..8265993385f 100644
--- a/dlls/shell32/shlview_cmenu.c
+++ b/dlls/shell32/shlview_cmenu.c
@@ -925,6 +925,12 @@ static HRESULT WINAPI ItemMenu_InvokeCommand(
DoCopyOrCut(This, lpcmi->hwnd, TRUE);
else if (strcmp(lpcmi->lpVerb,"properties")==0)
DoOpenProperties(This, lpcmi->hwnd);
+ else if (strcmp(lpcmi->lpVerb,"cut")==0)
+ DoCopyOrCut(This, lpcmi->hwnd, TRUE);
+ else if (strcmp(lpcmi->lpVerb,"copy")==0)
+ DoCopyOrCut(This, lpcmi->hwnd, FALSE);
+ else if (strcmp(lpcmi->lpVerb,"paste")==0)
+ DoPaste(This);
else {
FIXME("Unhandled string verb %s\n",debugstr_a(lpcmi->lpVerb));
return E_FAIL;
--
2.30.2

View File

@@ -1,3 +1,4 @@
Fixes: [34319] Add support for Paste in context menu
Fixes: [34322] Fix implementation of Cut file operation
Fixes: [34321] Fix Cut/Copy/Paste keyboard shortcuts in Total Commander
Disabled: true