Skip to content

Commit

Permalink
deploy: b0179b2
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Dec 4, 2024
1 parent 0ab44d1 commit 4680783
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 84 deletions.
4 changes: 2 additions & 2 deletions catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -2801,7 +2801,7 @@
"published": 1661149953000,
"rating": 10,
"ratingUsers": 157,
"updated": 1729450452000,
"updated": 1733320729000,
"users": 10176
},
"featured": true,
Expand All @@ -2819,7 +2819,7 @@
],
"name": "Taskbar Labels for Windows 11",
"twitter": "https://twitter.com/m417z",
"version": "1.3.2"
"version": "1.3.3"
}
},
"taskbar-language-indicator-layout-control": {
Expand Down
6 changes: 6 additions & 0 deletions changelogs/taskbar-labels.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.3.3 ([Dec 4, 2024](https://github.com/ramensoftware/windhawk-mods/blob/b0179b2e31ee74e302077bfb2de1b7cdfc6092d7/mods/taskbar-labels.wh.cpp))

* The "Minimum taskbar item width" option can now be set to any value. Only 44 or larger values were previously supported.
* Fixed a crash which could occur in some cases due to an incorrect running indicator width calculation.
* Fixed taskbar settings (the "Combine taskbar buttons and hide labels" option) affecting some of the taskbar behavior, such as left click on combined items.

## 1.3.2 ([Oct 20, 2024](https://github.com/ramensoftware/windhawk-mods/blob/0951986351d82332cd99a2335f16f6fbcb22033b/mods/taskbar-labels.wh.cpp))

* Added an option exclude programs by application ids.
Expand Down
177 changes: 109 additions & 68 deletions mods/taskbar-labels.wh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.2
// @version 1.3.3
// @author m417z
// @github https://github.com/m417z
// @twitter https://twitter.com/m417z
Expand Down Expand Up @@ -278,16 +278,12 @@ FrameworkElement FindChildByClassName(FrameworkElement element,
}

HWND GetTaskbarWnd() {
static HWND hTaskbarWnd;
HWND hTaskbarWnd = FindWindow(L"Shell_TrayWnd", nullptr);

if (!hTaskbarWnd) {
HWND hWnd = FindWindow(L"Shell_TrayWnd", nullptr);

DWORD processId = 0;
if (hWnd && GetWindowThreadProcessId(hWnd, &processId) &&
processId == GetCurrentProcessId()) {
hTaskbarWnd = hWnd;
}
DWORD processId = 0;
if (!hTaskbarWnd || !GetWindowThreadProcessId(hTaskbarWnd, &processId) ||
processId != GetCurrentProcessId()) {
return nullptr;
}

return hTaskbarWnd;
Expand Down Expand Up @@ -382,6 +378,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;
Expand Down Expand Up @@ -1035,18 +1033,21 @@ void UpdateTaskListButtonWithLabelStyle(

double minWidth = 0;

if (indicatorStyle == IndicatorStyle::centerFixed) {
// Without this, the indicator isn't centered.
minWidth = indicatorElement.Width();
} else if (indicatorStyle == IndicatorStyle::centerDynamic) {
if (firstColumnWidthPixels > 0) {
minWidth = indicatorElement.Width() * taskListButtonWidth /
firstColumnWidthPixels;
}
} else if (indicatorStyle == IndicatorStyle::fullWidth) {
minWidth = taskListButtonWidth - 6;
if (minWidth < 0) {
minWidth = 0;
double indicatorElementWidth = indicatorElement.Width();
if (indicatorElementWidth > 0) {
if (indicatorStyle == IndicatorStyle::centerFixed) {
// Without this, the indicator isn't centered.
minWidth = indicatorElementWidth;
} else if (indicatorStyle == IndicatorStyle::centerDynamic) {
if (firstColumnWidthPixels > 0) {
minWidth = indicatorElementWidth * taskListButtonWidth /
firstColumnWidthPixels;
}
} else if (indicatorStyle == IndicatorStyle::fullWidth) {
minWidth = taskListButtonWidth - 6;
if (minWidth < 0) {
minWidth = 0;
}
}
}

Expand All @@ -1058,11 +1059,13 @@ void UpdateTaskListButtonWithLabelStyle(
double currentMinWidth = indicatorElement.MinWidth();
if (minWidth != currentMinWidth) {
indicatorElement.MinWidth(0);
indicatorElement.Dispatcher().TryRunAsync(
winrt::Windows::UI::Core::CoreDispatcherPriority::High,
[indicatorElement, minWidth]() {
indicatorElement.MinWidth(minWidth);
});
if (minWidth > 0) {
indicatorElement.Dispatcher().TryRunAsync(
winrt::Windows::UI::Core::CoreDispatcherPriority::High,
[indicatorElement, minWidth]() {
indicatorElement.MinWidth(minWidth);
});
}
}
} else {
indicatorElement.MinWidth(minWidth);
Expand Down Expand Up @@ -1387,36 +1390,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
Expand All @@ -1430,8 +1403,8 @@ HRESULT ITaskbarButton_get_MinScalableWidth_Hook(void* pThis, float* minWidth) {
*minWidth > 0) {
// Allow to create many taskbar items before overflow appears.
int minimumTaskbarItemWidth = g_settings.minimumTaskbarItemWidth;
if (minimumTaskbarItemWidth < 44) {
minimumTaskbarItemWidth = 44;
if (minimumTaskbarItemWidth < 1) {
minimumTaskbarItemWidth = 1;
Wh_Log(L"minimumTaskbarItemWidth too small, using %d",
minimumTaskbarItemWidth);
}
Expand Down Expand Up @@ -1622,6 +1595,67 @@ TaskListGroupViewModel_ITaskbarAppItemViewModel_get_HasLabel_Hook(
return ret;
}

using RegGetValueW_t = decltype(&RegGetValueW);
RegGetValueW_t RegGetValueW_Original;
LONG WINAPI RegGetValueW_Hook(HKEY hkey,
LPCWSTR lpSubKey,
LPCWSTR lpValue,
DWORD dwFlags,
LPDWORD pdwType,
PVOID pvData,
LPDWORD pcbData) {
LONG ret = RegGetValueW_Original(hkey, lpSubKey, lpValue, dwFlags, pdwType,
pvData, pcbData);

if (hkey == HKEY_CURRENT_USER && lpSubKey &&
_wcsicmp(
lpSubKey,
LR"(SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced)") ==
0 &&
lpValue &&
(_wcsicmp(lpValue, L"TaskbarGlomLevel") == 0 ||
_wcsicmp(lpValue, L"MMTaskbarGlomLevel") == 0) &&
dwFlags == RRF_RT_REG_DWORD && pvData && pcbData &&
*pcbData == sizeof(DWORD)) {
Wh_Log(L">");

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) {
taskbarGlomLevel = 0;
} else if (taskbarGlomLevel == 0) {
taskbarGlomLevel = 2;
}
}

if (g_overrideGroupingMode) {
if (taskbarGlomLevel == 0) {
taskbarGlomLevel = 2;
} else {
taskbarGlomLevel = 0;
}
}

Wh_Log(L"Overriding TaskbarGlomLevel: %u->%u", taskbarGlomLevelOriginal,
taskbarGlomLevel);
*(DWORD*)pvData = taskbarGlomLevel;

if (pdwType) {
*pdwType = REG_DWORD;
}

ret = ERROR_SUCCESS;
}

return ret;
}

void* wil_Feature_GetImpl_Original;

using WilFeatureTraits_Feature_29785186_IsEnabled_t =
Expand Down Expand Up @@ -2142,6 +2176,15 @@ bool HookTaskbarViewDllSymbols(HMODULE module) {
// Taskbar.View.dll, ExplorerExtensions.dll
SYMBOL_HOOK symbolHooks[] = //
{
{
{
LR"(public: __cdecl winrt::impl::consume_WindowsUdk_UI_Shell_ITaskbarSettings5<struct winrt::WindowsUdk::UI::Shell::TaskbarSettings>::GroupingMode(void)const )",
LR"(public: __cdecl winrt::impl::consume_WindowsUdk_UI_Shell_ITaskbarSettings5<struct winrt::WindowsUdk::UI::Shell::TaskbarSettings>::GroupingMode(void)const __ptr64)",
},
(void**)&TaskbarSettings_GroupingMode_Original,
nullptr,
true,
},
{
{
LR"(public: virtual int __cdecl winrt::impl::produce<struct winrt::Taskbar::implementation::TaskListButton,struct winrt::Taskbar::ITaskListButton>::get_IsRunning(bool *))",
Expand Down Expand Up @@ -2189,15 +2232,6 @@ bool HookTaskbarViewDllSymbols(HMODULE module) {
(void**)&TaskListButton_Icon_Original,
(void*)TaskListButton_Icon_Hook,
},
{
{
LR"(public: __cdecl winrt::impl::consume_WindowsUdk_UI_Shell_ITaskbarSettings5<struct winrt::WindowsUdk::UI::Shell::TaskbarSettings>::GroupingMode(void)const )",
LR"(public: __cdecl winrt::impl::consume_WindowsUdk_UI_Shell_ITaskbarSettings5<struct winrt::WindowsUdk::UI::Shell::TaskbarSettings>::GroupingMode(void)const __ptr64)",
},
(void**)&TaskbarSettings_GroupingMode_Original,
(void*)TaskbarSettings_GroupingMode_Hook,
true,
},
{
{
LR"(public: virtual int __cdecl winrt::impl::produce<struct winrt::Taskbar::implementation::TaskListButton,struct winrt::Taskbar::ITaskbarButton>::get_MinScalableWidth(float *))",
Expand Down Expand Up @@ -2380,6 +2414,13 @@ BOOL ModInitWithTaskbarView(HMODULE taskbarViewModule) {
if (!HookTaskbarDllSymbols()) {
return FALSE;
}
} else {
HMODULE kernelBaseModule = GetModuleHandle(L"kernelbase.dll");
FARPROC pKernelBaseRegGetValueW =
GetProcAddress(kernelBaseModule, "RegGetValueW");
Wh_SetFunctionHook((void*)pKernelBaseRegGetValueW,
(void*)RegGetValueW_Hook,
(void**)&RegGetValueW_Original);
}

return TRUE;
Expand Down
30 changes: 16 additions & 14 deletions updates.atom
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,27 @@
<feed xmlns="http://www.w3.org/2005/Atom">
<id>https://windhawk.net/</id>
<title>Windhawk Mod Updates</title>
<updated>2024-12-02T17:23:58.000Z</updated>
<updated>2024-12-04T13:58:49.000Z</updated>
<generator>https://github.com/jpmonette/feed</generator>
<link rel="alternate" href="https://windhawk.net/"/>
<subtitle>Updates in the official collection of Windhawk mods</subtitle>
<icon>https://windhawk.net/favicon.ico</icon>
<rights>Ramen Software</rights>
<entry>
<title type="html"><![CDATA[Taskbar Labels for Windows 11 1.3.3]]></title>
<id>https://windhawk.net/mods/taskbar-labels#b0179b2e31ee74e302077bfb2de1b7cdfc6092d7</id>
<link href="https://windhawk.net/mods/taskbar-labels"/>
<updated>2024-12-04T13:58:49.000Z</updated>
<content type="html"><![CDATA[<ul>
<li>The "Minimum taskbar item width" option can now be set to any value. Only 44 or larger values were previously supported.</li>
<li>Fixed a crash which could occur in some cases due to an incorrect running indicator width calculation.</li>
<li>Fixed taskbar settings (the "Combine taskbar buttons and hide labels" option) affecting some of the taskbar behavior, such as left click on combined items.</li>
</ul>]]></content>
<author>
<name>m417z</name>
<uri>https://github.com/m417z</uri>
</author>
</entry>
<entry>
<title type="html"><![CDATA[Click on empty taskbar space 1.8]]></title>
<id>https://windhawk.net/mods/taskbar-empty-space-clicks#10dd219bec0369013eeeb9a3c0bee7efc3987f41</id>
Expand Down Expand Up @@ -289,17 +304,4 @@ center, etc. to another monitor.</p>
<uri>https://github.com/m417z</uri>
</author>
</entry>
<entry>
<title type="html"><![CDATA[Custom Shutdown Dialog 1.1.0]]></title>
<id>https://windhawk.net/mods/custom-shutdown-dialog#f7f83c31e2fde1cd1bdcf110318ae9e9d319ae33</id>
<link href="https://windhawk.net/mods/custom-shutdown-dialog"/>
<updated>2024-11-10T11:23:48.000Z</updated>
<content type="html"><![CDATA[<ul>
<li>Add ability to override logoff dialog (used in Windows XP Explorer)</li>
</ul>]]></content>
<author>
<name>aubymori</name>
<uri>https://github.com/aubymori</uri>
</author>
</entry>
</feed>

0 comments on commit 4680783

Please sign in to comment.