From 4ed451fc254efa5565634bfa69e4d3716a01fd3d Mon Sep 17 00:00:00 2001 From: Michael Maltsev <4129781+m417z@users.noreply.github.com> Date: Thu, 12 Dec 2024 12:13:50 +0200 Subject: [PATCH 1/3] pr_validation.py: Add Ingan121 Twitter account --- .github/pr_validation.py | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/pr_validation.py b/.github/pr_validation.py index 93061c04b..aa869b1a4 100644 --- a/.github/pr_validation.py +++ b/.github/pr_validation.py @@ -28,6 +28,7 @@ 'https://github.com/kawapure': 'kawaipure', 'https://github.com/TorutheRedFox': 'TorutheRedFox', 'https://github.com/u3l6': 'u_3l6', + 'https://github.com/Ingan121': 'Ingan121', } MOD_METADATA_PARAMS = { From 17e0c80c827a71f9a6a66079eaaae4dd289fecf9 Mon Sep 17 00:00:00 2001 From: Michael Maltsev <4129781+m417z@users.noreply.github.com> Date: Fri, 13 Dec 2024 02:09:13 +0200 Subject: [PATCH 2/3] Taskbar Labels for Windows 11 v1.3.4 (#1339) * Fixed thumbnail labels incorrectly showing or not showing when using some modes. * Added an option to always show thumbnail labels. By default, thumbnail labels are shown on hover only if taskbar labels are hidden, but that might not be applied for all customizations that this mod offers. * Fixed restoring labels on mod unload. --- mods/taskbar-labels.wh.cpp | 78 +++++++++++++++++++++++++++++--------- 1 file changed, 60 insertions(+), 18 deletions(-) diff --git a/mods/taskbar-labels.wh.cpp b/mods/taskbar-labels.wh.cpp index 7df9655e9..de50da692 100644 --- a/mods/taskbar-labels.wh.cpp +++ b/mods/taskbar-labels.wh.cpp @@ -2,7 +2,7 @@ // @id taskbar-labels // @name Taskbar Labels for Windows 11 // @description Customize text labels and combining for running programs on the taskbar (Windows 11 only) -// @version 1.3.3 +// @version 1.3.4 // @author m417z // @github https://github.com/m417z // @twitter https://twitter.com/m417z @@ -135,6 +135,12 @@ Labels can also be shown or hidden per-program in the settings. $name: Left and right padding size - spaceBetweenIconAndLabel: 8 $name: Space between icon and label +- alwaysShowThumbnailLabels: false + $name: Always show thumbnail labels + $description: >- + By default, thumbnail labels are shown on hover only if taskbar labels are + hidden, but that might not be applied for all customizations that this mod + offers - labelForSingleItem: "%name%" $name: Label for a single item $description: >- @@ -212,6 +218,7 @@ struct { int fontSize; int leftAndRightPaddingSize; int spaceBetweenIconAndLabel; + bool alwaysShowThumbnailLabels; string_setting_unique_ptr labelForSingleItem; string_setting_unique_ptr labelForMultipleItems; } g_settings; @@ -378,8 +385,6 @@ void RecalculateLabels() { g_applyingSettings = false; } -void* TaskbarSettings_GroupingMode_Original; - using TaskListButton_get_IsRunning_t = HRESULT(WINAPI*)(void* pThis, bool* running); TaskListButton_get_IsRunning_t TaskListButton_get_IsRunning_Original; @@ -1390,6 +1395,36 @@ void WINAPI TaskListButton_Icon_Hook(void* pThis, LONG_PTR randomAccessStream) { } } +using TaskbarSettings_GroupingMode_t = DWORD(WINAPI*)(void* pThis); +TaskbarSettings_GroupingMode_t TaskbarSettings_GroupingMode_Original; +DWORD WINAPI TaskbarSettings_GroupingMode_Hook(void* pThis) { + Wh_Log(L">"); + + DWORD ret = TaskbarSettings_GroupingMode_Original(pThis); + + if (!g_unloading) { + // 0 - Always + // 1 - When taskbar is full + // 2 - Never + if (g_settings.mode == Mode::noLabelsWithCombining || + g_settings.mode == Mode::labelsWithCombining) { + ret = 0; + } else if (ret == 0) { + ret = 2; + } + } + + if (g_overrideGroupingMode) { + if (ret == 0) { + ret = 2; + } else { + ret = 0; + } + } + + return ret; +} + using ITaskbarButton_get_MinScalableWidth_t = HRESULT(WINAPI*)(void* pThis, float* minWidth); ITaskbarButton_get_MinScalableWidth_t @@ -1619,15 +1654,20 @@ LONG WINAPI RegGetValueW_Hook(HKEY hkey, *pcbData == sizeof(DWORD)) { Wh_Log(L">"); - DWORD taskbarGlomLevel = (ret = ERROR_SUCCESS) ? *(DWORD*)pvData : 0; + DWORD taskbarGlomLevel = (ret == ERROR_SUCCESS) ? *(DWORD*)pvData : 0; DWORD taskbarGlomLevelOriginal = taskbarGlomLevel; if (!g_unloading) { - // 0 - Always - // 1 - When taskbar is full - // 2 - Never - if (g_settings.mode == Mode::noLabelsWithCombining || - g_settings.mode == Mode::labelsWithCombining) { + // This value is used by native code for thumbnail titles and maybe + // other things. The value for WinUI code is overridden in + // TaskbarSettings_GroupingMode_Hook. + // + // 0 - Always (show thumb titles) + // 1 - When taskbar is full (hide thumb titles, adaptive) + // 2 - Never (hide thumb titles, adaptive) + if (g_settings.alwaysShowThumbnailLabels || + g_settings.mode == Mode::noLabelsWithCombining || + g_settings.mode == Mode::noLabelsWithoutCombining) { taskbarGlomLevel = 0; } else if (taskbarGlomLevel == 0) { taskbarGlomLevel = 2; @@ -1756,6 +1796,8 @@ void LoadSettings() { Wh_GetIntSetting(L"leftAndRightPaddingSize"); g_settings.spaceBetweenIconAndLabel = Wh_GetIntSetting(L"spaceBetweenIconAndLabel"); + g_settings.alwaysShowThumbnailLabels = + Wh_GetIntSetting(L"alwaysShowThumbnailLabels"); g_settings.labelForSingleItem.reset( Wh_GetStringSetting(L"labelForSingleItem")); g_settings.labelForMultipleItems.reset( @@ -2176,15 +2218,6 @@ bool HookTaskbarViewDllSymbols(HMODULE module) { // Taskbar.View.dll, ExplorerExtensions.dll SYMBOL_HOOK symbolHooks[] = // { - { - { - LR"(public: __cdecl winrt::impl::consume_WindowsUdk_UI_Shell_ITaskbarSettings5::GroupingMode(void)const )", - LR"(public: __cdecl winrt::impl::consume_WindowsUdk_UI_Shell_ITaskbarSettings5::GroupingMode(void)const __ptr64)", - }, - (void**)&TaskbarSettings_GroupingMode_Original, - nullptr, - true, - }, { { LR"(public: virtual int __cdecl winrt::impl::produce::get_IsRunning(bool *))", @@ -2232,6 +2265,15 @@ bool HookTaskbarViewDllSymbols(HMODULE module) { (void**)&TaskListButton_Icon_Original, (void*)TaskListButton_Icon_Hook, }, + { + { + LR"(public: __cdecl winrt::impl::consume_WindowsUdk_UI_Shell_ITaskbarSettings5::GroupingMode(void)const )", + LR"(public: __cdecl winrt::impl::consume_WindowsUdk_UI_Shell_ITaskbarSettings5::GroupingMode(void)const __ptr64)", + }, + (void**)&TaskbarSettings_GroupingMode_Original, + (void*)TaskbarSettings_GroupingMode_Hook, + true, + }, { { LR"(public: virtual int __cdecl winrt::impl::produce::get_MinScalableWidth(float *))", From 37fce381dc197fbd1858b833d6ca0475acb40a54 Mon Sep 17 00:00:00 2001 From: Michael Maltsev <4129781+m417z@users.noreply.github.com> Date: Fri, 13 Dec 2024 03:57:20 +0200 Subject: [PATCH 3/3] Taskbar Labels for Windows 11 v1.3.5 (#1340) * Undid the fix of thumbnail labels incorrectly showing or not showing when using some modes, since the fix had unintended side effects. * Reimplemented an option to always show thumbnail labels, so that it can still be used as a workaround. --- mods/taskbar-labels.wh.cpp | 141 ++++++++++++++++++++++--------------- 1 file changed, 86 insertions(+), 55 deletions(-) diff --git a/mods/taskbar-labels.wh.cpp b/mods/taskbar-labels.wh.cpp index de50da692..5db819b88 100644 --- a/mods/taskbar-labels.wh.cpp +++ b/mods/taskbar-labels.wh.cpp @@ -2,7 +2,7 @@ // @id taskbar-labels // @name Taskbar Labels for Windows 11 // @description Customize text labels and combining for running programs on the taskbar (Windows 11 only) -// @version 1.3.4 +// @version 1.3.5 // @author m417z // @github https://github.com/m417z // @twitter https://twitter.com/m417z @@ -385,6 +385,8 @@ void RecalculateLabels() { g_applyingSettings = false; } +void* TaskbarSettings_GroupingMode_Original; + using TaskListButton_get_IsRunning_t = HRESULT(WINAPI*)(void* pThis, bool* running); TaskListButton_get_IsRunning_t TaskListButton_get_IsRunning_Original; @@ -562,6 +564,29 @@ double CalculateTaskbarItemWidth(FrameworkElement taskbarFrameRepeaterElement, return width; } +using CTaskListThumbnailWnd_DisplayUI_t = void*(WINAPI*)(void* pThis, + void* param1, + void* param2, + void* param3, + DWORD flags); +CTaskListThumbnailWnd_DisplayUI_t CTaskListThumbnailWnd_DisplayUI_Original; +void* WINAPI CTaskListThumbnailWnd_DisplayUI_Hook(void* pThis, + void* param1, + void* param2, + void* param3, + DWORD flags) { + Wh_Log(L">"); + + if (g_settings.alwaysShowThumbnailLabels) { + flags |= 0x01; + } + + void* ret = CTaskListThumbnailWnd_DisplayUI_Original(pThis, param1, param2, + param3, flags); + + return ret; +} + using CTaskListWnd__GetTBGroupFromGroup_t = void*(WINAPI*)(void* pThis, void* taskGroup, int* index); @@ -1395,36 +1420,6 @@ void WINAPI TaskListButton_Icon_Hook(void* pThis, LONG_PTR randomAccessStream) { } } -using TaskbarSettings_GroupingMode_t = DWORD(WINAPI*)(void* pThis); -TaskbarSettings_GroupingMode_t TaskbarSettings_GroupingMode_Original; -DWORD WINAPI TaskbarSettings_GroupingMode_Hook(void* pThis) { - Wh_Log(L">"); - - DWORD ret = TaskbarSettings_GroupingMode_Original(pThis); - - if (!g_unloading) { - // 0 - Always - // 1 - When taskbar is full - // 2 - Never - if (g_settings.mode == Mode::noLabelsWithCombining || - g_settings.mode == Mode::labelsWithCombining) { - ret = 0; - } else if (ret == 0) { - ret = 2; - } - } - - if (g_overrideGroupingMode) { - if (ret == 0) { - ret = 2; - } else { - ret = 0; - } - } - - return ret; -} - using ITaskbarButton_get_MinScalableWidth_t = HRESULT(WINAPI*)(void* pThis, float* minWidth); ITaskbarButton_get_MinScalableWidth_t @@ -1658,16 +1653,11 @@ LONG WINAPI RegGetValueW_Hook(HKEY hkey, DWORD taskbarGlomLevelOriginal = taskbarGlomLevel; if (!g_unloading) { - // This value is used by native code for thumbnail titles and maybe - // other things. The value for WinUI code is overridden in - // TaskbarSettings_GroupingMode_Hook. - // - // 0 - Always (show thumb titles) - // 1 - When taskbar is full (hide thumb titles, adaptive) - // 2 - Never (hide thumb titles, adaptive) - if (g_settings.alwaysShowThumbnailLabels || - g_settings.mode == Mode::noLabelsWithCombining || - g_settings.mode == Mode::noLabelsWithoutCombining) { + // 0 - Always + // 1 - When taskbar is full + // 2 - Never + if (g_settings.mode == Mode::noLabelsWithCombining || + g_settings.mode == Mode::labelsWithCombining) { taskbarGlomLevel = 0; } else if (taskbarGlomLevel == 0) { taskbarGlomLevel = 2; @@ -2218,6 +2208,15 @@ bool HookTaskbarViewDllSymbols(HMODULE module) { // Taskbar.View.dll, ExplorerExtensions.dll SYMBOL_HOOK symbolHooks[] = // { + { + { + LR"(public: __cdecl winrt::impl::consume_WindowsUdk_UI_Shell_ITaskbarSettings5::GroupingMode(void)const )", + LR"(public: __cdecl winrt::impl::consume_WindowsUdk_UI_Shell_ITaskbarSettings5::GroupingMode(void)const __ptr64)", + }, + (void**)&TaskbarSettings_GroupingMode_Original, + nullptr, + true, + }, { { LR"(public: virtual int __cdecl winrt::impl::produce::get_IsRunning(bool *))", @@ -2265,15 +2264,6 @@ bool HookTaskbarViewDllSymbols(HMODULE module) { (void**)&TaskListButton_Icon_Original, (void*)TaskListButton_Icon_Hook, }, - { - { - LR"(public: __cdecl winrt::impl::consume_WindowsUdk_UI_Shell_ITaskbarSettings5::GroupingMode(void)const )", - LR"(public: __cdecl winrt::impl::consume_WindowsUdk_UI_Shell_ITaskbarSettings5::GroupingMode(void)const __ptr64)", - }, - (void**)&TaskbarSettings_GroupingMode_Original, - (void*)TaskbarSettings_GroupingMode_Hook, - true, - }, { { LR"(public: virtual int __cdecl winrt::impl::produce::get_MinScalableWidth(float *))", @@ -2355,8 +2345,13 @@ bool HookTaskbarViewDllSymbols(HMODULE module) { }, }; - return HookSymbolsWithOnlineCacheFallback(module, symbolHooks, - ARRAYSIZE(symbolHooks)); + if (!HookSymbolsWithOnlineCacheFallback(module, symbolHooks, + ARRAYSIZE(symbolHooks))) { + Wh_Log(L"HookSymbols failed"); + return false; + } + + return true; } bool HookTaskbarDllSymbols() { @@ -2366,6 +2361,33 @@ bool HookTaskbarDllSymbols() { return false; } + SYMBOL_HOOK taskbarDllHooks[] = { + { + { + LR"(public: virtual int __cdecl CTaskListThumbnailWnd::DisplayUI(struct ITaskBtnGroup *,struct ITaskItem *,struct ITaskItem *,unsigned long))", + LR"(public: virtual int __cdecl CTaskListThumbnailWnd::DisplayUI(struct ITaskBtnGroup * __ptr64,struct ITaskItem * __ptr64,struct ITaskItem * __ptr64,unsigned long) __ptr64)", + }, + (void**)&CTaskListThumbnailWnd_DisplayUI_Original, + (void*)CTaskListThumbnailWnd_DisplayUI_Hook, + }, + }; + + if (!HookSymbolsWithOnlineCacheFallback(module, taskbarDllHooks, + ARRAYSIZE(taskbarDllHooks))) { + Wh_Log(L"HookSymbols failed"); + return false; + } + + return true; +} + +bool HookTaskbarDllSymbolsOldImplementation() { + HMODULE module = LoadLibrary(L"taskbar.dll"); + if (!module) { + Wh_Log(L"Failed to load taskbar.dll"); + return false; + } + SYMBOL_HOOK taskbarDllHooks[] = { { { @@ -2433,8 +2455,13 @@ bool HookTaskbarDllSymbols() { }, }; - return HookSymbolsWithOnlineCacheFallback(module, taskbarDllHooks, - ARRAYSIZE(taskbarDllHooks)); + if (!HookSymbolsWithOnlineCacheFallback(module, taskbarDllHooks, + ARRAYSIZE(taskbarDllHooks))) { + Wh_Log(L"HookSymbols failed"); + return false; + } + + return true; } BOOL ModInitWithTaskbarView(HMODULE taskbarViewModule) { @@ -2453,10 +2480,14 @@ BOOL ModInitWithTaskbarView(HMODULE taskbarViewModule) { } if (!g_hasNativeLabelsImplementation) { - if (!HookTaskbarDllSymbols()) { + if (!HookTaskbarDllSymbolsOldImplementation()) { return FALSE; } } else { + if (!HookTaskbarDllSymbols()) { + return FALSE; + } + HMODULE kernelBaseModule = GetModuleHandle(L"kernelbase.dll"); FARPROC pKernelBaseRegGetValueW = GetProcAddress(kernelBaseModule, "RegGetValueW");