From 10a924a439623b2a3ead98f143f442f9fee40913 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Mon, 16 Dec 2024 22:17:39 +0000
Subject: [PATCH] deploy: 9c2f0424b09b758e4e82b06da5b4d94e206e05a4
---
catalog.json | 4 +-
.../taskbar-notification-icon-spacing.md | 5 +
mods/taskbar-notification-icon-spacing.wh.cpp | 164 ++++++++++--------
updates.atom | 35 ++--
4 files changed, 113 insertions(+), 95 deletions(-)
diff --git a/catalog.json b/catalog.json
index 03f3b73a4..9a7728fa5 100644
--- a/catalog.json
+++ b/catalog.json
@@ -3013,7 +3013,7 @@
"published": 1706376839000,
"rating": 10,
"ratingUsers": 99,
- "updated": 1729696417000,
+ "updated": 1734387432000,
"users": 4496
},
"metadata": {
@@ -3030,7 +3030,7 @@
],
"name": "Taskbar tray icon spacing",
"twitter": "https://twitter.com/m417z",
- "version": "1.1"
+ "version": "1.1.1"
}
},
"taskbar-notification-icons-show-all": {
diff --git a/changelogs/taskbar-notification-icon-spacing.md b/changelogs/taskbar-notification-icon-spacing.md
index 09500b8b5..37bc13926 100644
--- a/changelogs/taskbar-notification-icon-spacing.md
+++ b/changelogs/taskbar-notification-icon-spacing.md
@@ -1,3 +1,8 @@
+## 1.1.1 ([Dec 16, 2024](https://github.com/ramensoftware/windhawk-mods/blob/9c2f0424b09b758e4e82b06da5b4d94e206e05a4/mods/taskbar-notification-icon-spacing.wh.cpp))
+
+* Fixed buggy tray overflow placement when it's shown at the first time after system startup.
+* Fixed tray overflow styles not being restored on mod unload.
+
## 1.1 ([Oct 23, 2024](https://github.com/ramensoftware/windhawk-mods/blob/a7c329d411e81a6e0b20c90efc77c36fca9fec5a/mods/taskbar-notification-icon-spacing.wh.cpp))
* Renamed from "Taskbar notification icon spacing" to "Taskbar tray icon spacing", as tray is the more familiar term.
diff --git a/mods/taskbar-notification-icon-spacing.wh.cpp b/mods/taskbar-notification-icon-spacing.wh.cpp
index db6800a7c..15432a7e4 100644
--- a/mods/taskbar-notification-icon-spacing.wh.cpp
+++ b/mods/taskbar-notification-icon-spacing.wh.cpp
@@ -2,7 +2,7 @@
// @id taskbar-notification-icon-spacing
// @name Taskbar tray icon spacing
// @description Reduce or increase the spacing between tray icons on the taskbar (Windows 11 only)
-// @version 1.1
+// @version 1.1.1
// @author m417z
// @github https://github.com/m417z
// @twitter https://twitter.com/m417z
@@ -63,6 +63,7 @@ versions check out [7+ Taskbar Tweaker](https://tweaker.ramensoftware.com/).
#include
+#include
#include
#include
@@ -81,25 +82,23 @@ struct {
int overflowIconsPerRow;
} g_settings;
+std::atomic g_unloading;
+
using FrameworkElementLoadedEventRevoker = winrt::impl::event_revoker<
IFrameworkElement,
&winrt::impl::abi::type::remove_Loaded>;
std::list g_autoRevokerList;
-bool g_overflowApplied;
+winrt::weak_ref g_overflowRootGrid;
HWND GetTaskbarWnd() {
- static HWND hTaskbarWnd;
-
- if (!hTaskbarWnd) {
- HWND hWnd = FindWindow(L"Shell_TrayWnd", nullptr);
+ HWND hTaskbarWnd = 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;
@@ -447,18 +446,18 @@ bool ApplyStyle(XamlRoot xamlRoot, int width) {
return somethingSucceeded;
}
-using IconView_IconView_t = void(WINAPI*)(PVOID pThis);
+using IconView_IconView_t = void*(WINAPI*)(void* pThis);
IconView_IconView_t IconView_IconView_Original;
-void WINAPI IconView_IconView_Hook(PVOID pThis) {
+void* WINAPI IconView_IconView_Hook(void* pThis) {
Wh_Log(L">");
- IconView_IconView_Original(pThis);
+ void* ret = IconView_IconView_Original(pThis);
FrameworkElement iconView = nullptr;
((IUnknown**)pThis)[1]->QueryInterface(winrt::guid_of(),
winrt::put_abi(iconView));
if (!iconView) {
- return;
+ return ret;
}
g_autoRevokerList.emplace_back();
@@ -498,9 +497,7 @@ void WINAPI IconView_IconView_Hook(PVOID pThis) {
iconView, g_settings.notificationIconWidth);
} else if (IsChildOfElementByName(iconView, L"MainStack") ||
IsChildOfElementByName(iconView,
- L"NonActivatableStack") ||
- IsChildOfElementByName(iconView,
- L"ControlCenterButton")) {
+ L"NonActivatableStack")) {
ApplyNotifyIconViewStyle(
iconView, g_settings.notificationIconWidth);
}
@@ -512,32 +509,11 @@ void WINAPI IconView_IconView_Hook(PVOID pThis) {
}
}
});
-}
-
-using OverflowXamlIslandManager_ShowWindow_t =
- void(WINAPI*)(void* pThis, POINT pt, int inputDeviceKind);
-OverflowXamlIslandManager_ShowWindow_t
- OverflowXamlIslandManager_ShowWindow_Original;
-void WINAPI OverflowXamlIslandManager_ShowWindow_Hook(void* pThis,
- POINT pt,
- int inputDeviceKind) {
- Wh_Log(L">");
-
- OverflowXamlIslandManager_ShowWindow_Original(pThis, pt, inputDeviceKind);
-
- if (g_overflowApplied) {
- return;
- }
-
- g_overflowApplied = true;
- FrameworkElement overflowRootGrid = nullptr;
- ((IUnknown**)pThis)[5]->QueryInterface(winrt::guid_of(),
- winrt::put_abi(overflowRootGrid));
- if (!overflowRootGrid) {
- return;
- }
+ return ret;
+}
+void ApplyOverflowStyle(FrameworkElement overflowRootGrid) {
Controls::WrapGrid wrapGrid = nullptr;
FrameworkElement child = overflowRootGrid;
@@ -554,13 +530,16 @@ void WINAPI OverflowXamlIslandManager_ShowWindow_Hook(void* pThis,
return;
}
- int width = g_settings.overflowIconWidth;
+ int width = g_unloading ? 40 : g_settings.overflowIconWidth;
+ int maxRows = g_unloading ? 5 : g_settings.overflowIconsPerRow;
+ Wh_Log(
+ L"Setting ItemWidth/ItemHeight=%d, MaximumRowsOrColumns=%d for "
+ L"WrapGrid",
+ width, maxRows);
- Wh_Log(L"Setting ItemWidth, ItemWidth=%d for WrapGrid", width);
wrapGrid.ItemWidth(width);
wrapGrid.ItemHeight(width);
-
- wrapGrid.MaximumRowsOrColumns(g_settings.overflowIconsPerRow);
+ wrapGrid.MaximumRowsOrColumns(maxRows);
EnumChildElements(wrapGrid, [width](FrameworkElement child) {
auto className = winrt::get_class_name(child);
@@ -579,12 +558,42 @@ void WINAPI OverflowXamlIslandManager_ShowWindow_Hook(void* pThis,
});
}
+using OverflowXamlIslandManager_InitializeIfNeeded_t =
+ void(WINAPI*)(void* pThis);
+OverflowXamlIslandManager_InitializeIfNeeded_t
+ OverflowXamlIslandManager_InitializeIfNeeded_Original;
+void WINAPI OverflowXamlIslandManager_InitializeIfNeeded_Hook(void* pThis) {
+ Wh_Log(L">");
+
+ OverflowXamlIslandManager_InitializeIfNeeded_Original(pThis);
+
+ if (g_overflowRootGrid.get()) {
+ return;
+ }
+
+ FrameworkElement overflowRootGrid = nullptr;
+ ((IUnknown**)pThis)[5]->QueryInterface(winrt::guid_of(),
+ winrt::put_abi(overflowRootGrid));
+ if (!overflowRootGrid) {
+ Wh_Log(L"No OverflowRootGrid");
+ return;
+ }
+
+ if (!overflowRootGrid.IsLoaded()) {
+ Wh_Log(L"OverflowRootGrid not loaded");
+ return;
+ }
+
+ g_overflowRootGrid = overflowRootGrid;
+ ApplyOverflowStyle(overflowRootGrid);
+}
+
void* CTaskBand_ITaskListWndSite_vftable;
-using CTaskBand_GetTaskbarHost_t = PVOID(WINAPI*)(PVOID pThis, PVOID* result);
+using CTaskBand_GetTaskbarHost_t = void*(WINAPI*)(void* pThis, void** result);
CTaskBand_GetTaskbarHost_t CTaskBand_GetTaskbarHost_Original;
-using std__Ref_count_base__Decref_t = void(WINAPI*)(PVOID pThis);
+using std__Ref_count_base__Decref_t = void(WINAPI*)(void* pThis);
std__Ref_count_base__Decref_t std__Ref_count_base__Decref_Original;
XamlRoot GetTaskbarXamlRoot(HWND hTaskbarWnd) {
@@ -593,19 +602,19 @@ XamlRoot GetTaskbarXamlRoot(HWND hTaskbarWnd) {
return nullptr;
}
- PVOID taskBand = (PVOID)GetWindowLongPtr(hTaskSwWnd, 0);
- PVOID taskBandForTaskListWndSite = taskBand;
- for (int i = 0; *(PVOID*)taskBandForTaskListWndSite !=
+ void* taskBand = (void*)GetWindowLongPtr(hTaskSwWnd, 0);
+ void* taskBandForTaskListWndSite = taskBand;
+ for (int i = 0; *(void**)taskBandForTaskListWndSite !=
CTaskBand_ITaskListWndSite_vftable;
i++) {
if (i == 20) {
return nullptr;
}
- taskBandForTaskListWndSite = (PVOID*)taskBandForTaskListWndSite + 1;
+ taskBandForTaskListWndSite = (void**)taskBandForTaskListWndSite + 1;
}
- PVOID taskbarHostSharedPtr[2]{};
+ void* taskbarHostSharedPtr[2]{};
CTaskBand_GetTaskbarHost_Original(taskBandForTaskListWndSite,
taskbarHostSharedPtr);
if (!taskbarHostSharedPtr[0] && !taskbarHostSharedPtr[1]) {
@@ -630,17 +639,17 @@ XamlRoot GetTaskbarXamlRoot(HWND hTaskbarWnd) {
return result;
}
-using RunFromWindowThreadProc_t = void(WINAPI*)(PVOID parameter);
+using RunFromWindowThreadProc_t = void(WINAPI*)(void* parameter);
bool RunFromWindowThread(HWND hWnd,
RunFromWindowThreadProc_t proc,
- PVOID procParam) {
+ void* procParam) {
static const UINT runFromWindowThreadRegisteredMsg =
RegisterWindowMessage(L"Windhawk_RunFromWindowThread_" WH_MOD_ID);
struct RUN_FROM_WINDOW_THREAD_PARAM {
RunFromWindowThreadProc_t proc;
- PVOID procParam;
+ void* procParam;
};
DWORD dwThreadId = GetWindowThreadProcessId(hWnd, nullptr);
@@ -689,13 +698,13 @@ void LoadSettings() {
g_settings.overflowIconsPerRow = Wh_GetIntSetting(L"overflowIconsPerRow");
}
-void ApplySettings(int width) {
+void ApplySettings() {
struct ApplySettingsParam {
HWND hTaskbarWnd;
int width;
};
- Wh_Log(L"Applying settings: %d", width);
+ Wh_Log(L"Applying settings");
HWND hTaskbarWnd = GetTaskbarWnd();
if (!hTaskbarWnd) {
@@ -705,16 +714,15 @@ void ApplySettings(int width) {
ApplySettingsParam param{
.hTaskbarWnd = hTaskbarWnd,
- .width = width,
+ .width = g_unloading ? 32 : g_settings.notificationIconWidth,
};
RunFromWindowThread(
hTaskbarWnd,
- [](PVOID pParam) WINAPI {
+ [](void* pParam) WINAPI {
ApplySettingsParam& param = *(ApplySettingsParam*)pParam;
g_autoRevokerList.clear();
- g_overflowApplied = false;
auto xamlRoot = GetTaskbarXamlRoot(param.hTaskbarWnd);
if (!xamlRoot) {
@@ -725,6 +733,10 @@ void ApplySettings(int width) {
if (!ApplyStyle(xamlRoot, param.width)) {
Wh_Log(L"ApplyStyles failed");
}
+
+ if (auto overflowRootGrid = g_overflowRootGrid.get()) {
+ ApplyOverflowStyle(overflowRootGrid);
+ }
},
¶m);
}
@@ -755,34 +767,34 @@ bool HookTaskbarViewDllSymbols() {
IconView_IconView_Hook,
},
{
- {LR"(private: void __cdecl winrt::SystemTray::OverflowXamlIslandManager::ShowWindow(struct tagPOINT,enum winrt::WindowsUdk::UI::Shell::InputDeviceKind))"},
- &OverflowXamlIslandManager_ShowWindow_Original,
- OverflowXamlIslandManager_ShowWindow_Hook,
+ {LR"(private: void __cdecl winrt::SystemTray::OverflowXamlIslandManager::InitializeIfNeeded(void))"},
+ &OverflowXamlIslandManager_InitializeIfNeeded_Original,
+ OverflowXamlIslandManager_InitializeIfNeeded_Hook,
},
};
return HookSymbols(module, symbolHooks, ARRAYSIZE(symbolHooks));
}
-BOOL HookTaskbarDllSymbols() {
+bool HookTaskbarDllSymbols() {
HMODULE module = LoadLibrary(L"taskbar.dll");
if (!module) {
Wh_Log(L"Failed to load taskbar.dll");
- return FALSE;
+ return false;
}
WindhawkUtils::SYMBOL_HOOK taskbarDllHooks[] = {
{
{LR"(const CTaskBand::`vftable'{for `ITaskListWndSite'})"},
- (void**)&CTaskBand_ITaskListWndSite_vftable,
+ &CTaskBand_ITaskListWndSite_vftable,
},
{
{LR"(public: virtual class std::shared_ptr __cdecl CTaskBand::GetTaskbarHost(void)const )"},
- (void**)&CTaskBand_GetTaskbarHost_Original,
+ &CTaskBand_GetTaskbarHost_Original,
},
{
{LR"(public: void __cdecl std::_Ref_count_base::_Decref(void))"},
- (void**)&std__Ref_count_base__Decref_Original,
+ &std__Ref_count_base__Decref_Original,
},
};
@@ -808,13 +820,19 @@ BOOL Wh_ModInit() {
void Wh_ModAfterInit() {
Wh_Log(L">");
- ApplySettings(g_settings.notificationIconWidth);
+ ApplySettings();
}
-void Wh_ModUninit() {
+void Wh_ModBeforeUninit() {
Wh_Log(L">");
- ApplySettings(32);
+ g_unloading = true;
+
+ ApplySettings();
+}
+
+void Wh_ModUninit() {
+ Wh_Log(L">");
}
void Wh_ModSettingsChanged() {
@@ -822,5 +840,5 @@ void Wh_ModSettingsChanged() {
LoadSettings();
- ApplySettings(g_settings.notificationIconWidth);
+ ApplySettings();
}
diff --git a/updates.atom b/updates.atom
index 1587aa67c..f93a1fd96 100644
--- a/updates.atom
+++ b/updates.atom
@@ -2,12 +2,26 @@
https://windhawk.net/
Windhawk Mod Updates
- 2024-12-16T18:27:30.000Z
+ 2024-12-16T22:17:12.000Z
https://github.com/jpmonette/feed
Updates in the official collection of Windhawk mods
https://windhawk.net/favicon.ico
Ramen Software
+
+
+ https://windhawk.net/mods/taskbar-notification-icon-spacing#9c2f0424b09b758e4e82b06da5b4d94e206e05a4
+
+ 2024-12-16T22:17:12.000Z
+
+Fixed buggy tray overflow placement when it's shown at the first time after system startup.
+Fixed tray overflow styles not being restored on mod unload.
+]]>
+
+ m417z
+ https://github.com/m417z
+
+
https://windhawk.net/mods/explorer-details-better-file-sizes#4daa0db637b47f3da820ad7d1cdcc64236068d12
@@ -323,23 +337,4 @@ as a DWORD, set it to 1, and restart Explorer (or sign out and sign in).
]]><
https://github.com/m1lhaus
-
-
- https://windhawk.net/mods/tortoisegit-progress-animation-background-fix#23d47eaa50c0dd34b1bd7b843c4652f684198f14
-
- 2024-11-22T18:05:25.000Z
- TortoiseGit progress animation background fix for classic dark theme
-Under classic dark theme, TortoiseGit progress animation has a white background, thus looking as if something is broken.
-This mod fixes the progress animation background in classic dark theme by replacing the white background with a classic button face colour.
-Before:
-
-After:
-
-Known limitations
-There is still a brief flash of a white coloured box before the progress animation starts. I have tried various ways, but have been unable to get rid of that. If you have an idea how to fix that, please let me know!
]]>
-
- Roland Pihlakas
- https://github.com/levitation
-
-
\ No newline at end of file