From b809e9e8ed836794bd622db87a5a3ff7b5ffa5ca Mon Sep 17 00:00:00 2001 From: Valentin Radu Date: Thu, 26 May 2022 11:54:23 +0300 Subject: [PATCH] GUI: Support switching more pages using the number row on the keyboard --- ExplorerPatcher/GUI.c | 40 ++++++++++++++++++++++++++++-------- ExplorerPatcher/dllmain.c | 10 +++++++++ ExplorerPatcher/settings.reg | 4 +--- 3 files changed, 42 insertions(+), 12 deletions(-) diff --git a/ExplorerPatcher/GUI.c b/ExplorerPatcher/GUI.c index 00d53c1..c3921d7 100644 --- a/ExplorerPatcher/GUI.c +++ b/ExplorerPatcher/GUI.c @@ -3663,12 +3663,31 @@ static LRESULT CALLBACK GUI_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR return 0; } // this should be determined from the file, but for now it works - else if (wParam >= '1' && wParam <= '9' || wParam == '0') + else if (wParam >= '1' && wParam <= '9' || wParam == '0' || wParam == MapVirtualKeyW(0x0C, MAPVK_VSC_TO_VK_EX) || wParam == MapVirtualKeyW(0x0D, MAPVK_VSC_TO_VK_EX)) { - _this->tabOrder = 0; - GUI_SetSection(_this, TRUE, wParam == '0' ? 9 : wParam - '1'); - _this->bShouldAnnounceSelected = TRUE; - InvalidateRect(hWnd, NULL, FALSE); + int min_section = 0; + int max_section = 100; + for (unsigned int i = 0; i < 100; ++i) + { + if (_this->sectionNames[i][0] == 0) + { + max_section = i - 1; + break; + } + } + int new_section = 0; + if (wParam == MapVirtualKeyW(0x0C, MAPVK_VSC_TO_VK_EX)) new_section = 10; + else if (wParam == MapVirtualKeyW(0x0D, MAPVK_VSC_TO_VK_EX)) new_section = 11; + else new_section = (wParam == '0' ? 9 : wParam - '1'); + if (new_section < min_section) return 0; + if (new_section > max_section) return 0; + if (_this->section != new_section) + { + _this->tabOrder = 0; + GUI_SetSection(_this, TRUE, new_section); + _this->bShouldAnnounceSelected = TRUE; + InvalidateRect(hWnd, NULL, FALSE); + } return 0; } else if (wParam == VK_LEFT || wParam == VK_RIGHT) @@ -3700,10 +3719,13 @@ static LRESULT CALLBACK GUI_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR { new_section = min_section; } - _this->tabOrder = 0; - GUI_SetSection(_this, TRUE, new_section); - _this->bShouldAnnounceSelected = TRUE; - InvalidateRect(hWnd, NULL, FALSE); + if (_this->section != new_section) + { + _this->tabOrder = 0; + GUI_SetSection(_this, TRUE, new_section); + _this->bShouldAnnounceSelected = TRUE; + InvalidateRect(hWnd, NULL, FALSE); + } return 0; } else if (wParam == 'H' || wParam == VK_F1) diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index 87807ba..3e17d34 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -6343,7 +6343,9 @@ void WINAPI LoadSettings(LPARAM lParam) if (dwTemp != bDisableSpotlightIcon) { bDisableSpotlightIcon = dwTemp; +#ifdef _WIN64 if (IsSpotlightEnabled()) dwRefreshUIMask |= REFRESHUI_SPOTLIGHT; +#endif } dwSize = sizeof(DWORD); RegQueryValueExW( @@ -6367,6 +6369,7 @@ void WINAPI LoadSettings(LPARAM lParam) if (dwTemp != dwSpotlightUpdateSchedule) { dwSpotlightUpdateSchedule = dwTemp; +#ifdef _WIN64 if (IsSpotlightEnabled() && hWndServiceWindow) { if (dwSpotlightUpdateSchedule) @@ -6378,6 +6381,7 @@ void WINAPI LoadSettings(LPARAM lParam) KillTimer(hWndServiceWindow, 100); } } +#endif } dwTemp = FALSE; dwSize = sizeof(DWORD); @@ -9175,6 +9179,7 @@ BOOL SHELL32_CanDisplayWin8CopyDialogHook() #pragma region "Windows Spotlight customization" +#ifdef _WIN64 HKEY hKeySpotlight1 = NULL; HKEY hKeySpotlight2 = NULL; @@ -9233,6 +9238,7 @@ BOOL shell32_TrackPopupMenu(HMENU hMenu, UINT uFlags, int x, int y, int nReserve } return bRet; } +#endif #pragma endregion @@ -9259,14 +9265,18 @@ DWORD InjectBasicFunctions(BOOL bIsExplorer, BOOL bInstall) { if (bInstall) { +#ifdef _WIN64 if (DoesOSBuildSupportSpotlight()) { VnPatchIAT(hShell32, "user32.dll", "TrackPopupMenu", shell32_TrackPopupMenu); } else { +#endif VnPatchIAT(hShell32, "user32.dll", "TrackPopupMenu", TrackPopupMenuHook); +#ifdef _WIN64 } +#endif VnPatchIAT(hShell32, "user32.dll", "SystemParametersInfoW", DisableImmersiveMenus_SystemParametersInfoW); if (!bIsExplorer) { diff --git a/ExplorerPatcher/settings.reg b/ExplorerPatcher/settings.reg index 33f62f4..0801535 100644 --- a/ExplorerPatcher/settings.reg +++ b/ExplorerPatcher/settings.reg @@ -83,7 +83,6 @@ ;x 0 Large (default) "TaskbarSmallIcons"=dword:00000000 ;e -;e ;g Taskbar_Windows10Section @@ -530,9 +529,9 @@ ;s Spotlight_SpotlightOSCheck DoesOSBuildSupportSpotlight +;s Spotlight_SpotlightEnabledCheck IsSpotlightEnabled ;T Spotlight [HKEY_CURRENT_USER\Software\ExplorerPatcher] -;t When using Windows spotlight as desktop background: ;b Hide the "Learn about this picture" icon "SpotlightDisableIcon"=dword:00000000 ;c 8 Desktop context menu items @@ -558,7 +557,6 @@ ;x 43200 Every 12 hours ;x 86400 Once a day "SpotlightUpdateSchedule"=dword:00000000 -;s Spotlight_SpotlightEnabledCheck IsSpotlightEnabled ;u %SPOTLIGHTCLICK% ;spotlight_click ;t %SPOTLIGHTINFOTIP1%