Browse Source

Spotlight: Fixed a bug that had Spotlight context menu entries appear in some menus other than the desktop context menu

pull/1138/head 22000.708.46.1_87a2638
Valentin Radu 4 years ago
parent
commit
87a2638fb1
  1. 11
      ExplorerPatcher/dllmain.c
  2. 33
      ExplorerPatcher/utility.c

11
ExplorerPatcher/dllmain.c

@ -9183,6 +9183,7 @@ BOOL SHELL32_CanDisplayWin8CopyDialogHook()
HKEY hKeySpotlight1 = NULL; HKEY hKeySpotlight1 = NULL;
HKEY hKeySpotlight2 = NULL; HKEY hKeySpotlight2 = NULL;
BOOL bSpotlightIsDesktopContextMenu = FALSE;
LSTATUS shell32_RegCreateKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD Reserved, LPWSTR lpClass, DWORD dwOptions, REGSAM samDesired, const LPSECURITY_ATTRIBUTES lpSecurityAttributes, PHKEY phkResult, LPDWORD lpdwDisposition) LSTATUS shell32_RegCreateKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD Reserved, LPWSTR lpClass, DWORD dwOptions, REGSAM samDesired, const LPSECURITY_ATTRIBUTES lpSecurityAttributes, PHKEY phkResult, LPDWORD lpdwDisposition)
{ {
@ -9216,15 +9217,17 @@ LSTATUS shell32_RegSetValueExW(HKEY hKey, LPCWSTR lpValueName, DWORD Reserved, D
BOOL shell32_DeleteMenu(HMENU hMenu, UINT uPosition, UINT uFlags) BOOL shell32_DeleteMenu(HMENU hMenu, UINT uPosition, UINT uFlags)
{ {
if (uPosition == 0x7053 && IsSpotlightEnabled() && dwSpotlightDesktopMenuMask) if (uPosition == 0x7053 && IsSpotlightEnabled() && dwSpotlightDesktopMenuMask) bSpotlightIsDesktopContextMenu = TRUE;
{
SpotlightHelper(dwSpotlightDesktopMenuMask, GetDesktopWindow(), hMenu, NULL);
}
return DeleteMenu(hMenu, uPosition, uFlags); return DeleteMenu(hMenu, uPosition, uFlags);
} }
BOOL shell32_TrackPopupMenu(HMENU hMenu, UINT uFlags, int x, int y, int nReserved, HWND hWnd, const RECT* prcRect) BOOL shell32_TrackPopupMenu(HMENU hMenu, UINT uFlags, int x, int y, int nReserved, HWND hWnd, const RECT* prcRect)
{ {
if (IsSpotlightEnabled() && dwSpotlightDesktopMenuMask && RegisterWindowMessageW(L"WorkerW") == GetClassWord(GetParent(hWnd), GCW_ATOM) && bSpotlightIsDesktopContextMenu)
{
SpotlightHelper(dwSpotlightDesktopMenuMask, hWnd, hMenu, NULL);
}
bSpotlightIsDesktopContextMenu = FALSE;
BOOL bRet = TrackPopupMenuHook(hMenu, uFlags, x, y, nReserved, hWnd, prcRect); BOOL bRet = TrackPopupMenuHook(hMenu, uFlags, x, y, nReserved, hWnd, prcRect);
if (IsSpotlightEnabled() && dwSpotlightDesktopMenuMask) if (IsSpotlightEnabled() && dwSpotlightDesktopMenuMask)
{ {

33
ExplorerPatcher/utility.c

@ -1519,7 +1519,7 @@ void SpotlightHelper(DWORD dwOp, HWND hWnd, HMENU hMenu, LPPOINT pPt)
else if (!(dwOp & ~SPOP_INSERTMENU_ALL)) else if (!(dwOp & ~SPOP_INSERTMENU_ALL))
{ {
MENUITEMINFOW mii; MENUITEMINFOW mii;
int i = -1; int i = ARRAYSIZE(spop_insertmenu_ops) - 1;
while (1) while (1)
{ {
if (i == -1 ? ((dwOp & SPOP_INSERTMENU_INFOTIP1) || (dwOp & SPOP_INSERTMENU_INFOTIP2)) : (dwOp & spop_insertmenu_ops[i])) if (i == -1 ? ((dwOp & SPOP_INSERTMENU_INFOTIP1) || (dwOp & SPOP_INSERTMENU_INFOTIP2)) : (dwOp & spop_insertmenu_ops[i]))
@ -1548,28 +1548,31 @@ void SpotlightHelper(DWORD dwOp, HWND hWnd, HMENU hMenu, LPPOINT pPt)
{ {
if (i == -1) if (i == -1)
{ {
WCHAR* pCInit = mii.dwTypeData;
WCHAR* pC = wcschr(mii.dwTypeData, L'\r'); WCHAR* pC = wcschr(mii.dwTypeData, L'\r');
if (pC) if (pC)
{ {
pC[0] = 0; pC[0] = 0;
pC++;
WCHAR* pC2 = wcschr(pC, L'\r');
if (pC2)
{
pC2[0] = 0;
}
mii.dwTypeData = pC;
mii.fMask = MIIM_ID | MIIM_STRING | MIIM_DATA | MIIM_STATE; mii.fMask = MIIM_ID | MIIM_STRING | MIIM_DATA | MIIM_STATE;
mii.wID = 3999 + i - 1; mii.wID = 3999 + i - 1;
mii.dwItemData = SPOP_CLICKMENU_FIRST + i - 1; mii.dwItemData = SPOP_CLICKMENU_FIRST + i - 1;
mii.fType = MFT_STRING; mii.fType = MFT_STRING;
mii.fState = MFS_DISABLED; mii.fState = MFS_DISABLED;
if (dwOp & SPOP_INSERTMENU_INFOTIP1) if (dwOp & SPOP_INSERTMENU_INFOTIP2)
{ {
InsertMenuItemW(hMenu, GetMenuItemCount(hMenu) - 1, TRUE, &mii); InsertMenuItemW(hMenu, 3, TRUE, &mii);
} }
pC++; mii.dwTypeData = pCInit;
WCHAR* pC2 = wcschr(pC, L'\r');
if (pC2)
{
pC2[0] = 0;
}
mii.dwTypeData = pC;
} }
} }
mii.fMask = MIIM_ID | MIIM_STRING | MIIM_DATA | (i == -1 ? MIIM_STATE : 0); mii.fMask = MIIM_ID | MIIM_STRING | MIIM_DATA | (i == -1 ? MIIM_STATE : 0);
@ -1577,22 +1580,22 @@ void SpotlightHelper(DWORD dwOp, HWND hWnd, HMENU hMenu, LPPOINT pPt)
mii.dwItemData = SPOP_CLICKMENU_FIRST + i; mii.dwItemData = SPOP_CLICKMENU_FIRST + i;
mii.fType = MFT_STRING; mii.fType = MFT_STRING;
if (i == -1) mii.fState = MFS_DISABLED; if (i == -1) mii.fState = MFS_DISABLED;
if (i != -1 || (i == -1 && (dwOp & SPOP_INSERTMENU_INFOTIP2))) if (i != -1 || (i == -1 && (dwOp & SPOP_INSERTMENU_INFOTIP1)))
{ {
InsertMenuItemW(hMenu, GetMenuItemCount(hMenu) - 1, TRUE, &mii); InsertMenuItemW(hMenu, 3, TRUE, &mii);
} }
} }
free(buf); free(buf);
} }
} }
} }
i++; i--;
if (i >= ARRAYSIZE(spop_insertmenu_ops)) break; if (i < -1) break;
} }
mii.fMask = MIIM_FTYPE | MIIM_DATA; mii.fMask = MIIM_FTYPE | MIIM_DATA;
mii.dwItemData = 0; mii.dwItemData = 0;
mii.fType = MFT_SEPARATOR; mii.fType = MFT_SEPARATOR;
InsertMenuItemW(hMenu, GetMenuItemCount(hMenu) - 1, TRUE, &mii); InsertMenuItemW(hMenu, 3, TRUE, &mii);
} }
else if (dwOp >= SPOP_CLICKMENU_FIRST && dwOp <= SPOP_CLICKMENU_LAST) else if (dwOp >= SPOP_CLICKMENU_FIRST && dwOp <= SPOP_CLICKMENU_LAST)
{ {

Loading…
Cancel
Save