Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taskbar height and icon size v1.2.1 #368

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 52 additions & 6 deletions mods/taskbar-icon-size.wh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// @id taskbar-icon-size
// @name Taskbar height and icon size
// @description Control the taskbar height and icon size, improve icon quality (Windows 11 only)
// @version 1.2
// @version 1.2.1
// @author m417z
// @github https://github.com/m417z
// @twitter https://twitter.com/m417z
Expand Down Expand Up @@ -98,6 +98,7 @@ std::atomic<bool> g_unloading = false;

int g_originalTaskbarHeight;
int g_taskbarHeight;
bool g_inSystemTraySecondaryController_UpdateFrameSize;

double* double_48_value_Original;

Expand All @@ -124,16 +125,15 @@ ResourceDictionary_Lookup_Hook(void* pThis,
return ret;
}

auto valueDouble =
ret->try_as<winrt::Windows::Foundation::IReference<double>>();
auto valueDouble = ret->try_as<double>();
if (!valueDouble) {
return ret;
}

double newValueDouble = g_settings.taskbarButtonWidth;
if (newValueDouble != valueDouble.Value()) {
Wh_Log(L"Overriding value %s: %f->%f", keyString->c_str(),
valueDouble.Value(), newValueDouble);
if (newValueDouble != *valueDouble) {
Wh_Log(L"Overriding value %s: %f->%f", keyString->c_str(), *valueDouble,
newValueDouble);
*ret = winrt::box_value(newValueDouble);
}

Expand Down Expand Up @@ -281,6 +281,34 @@ void WINAPI TaskbarFrame_Height_double_Hook(void* pThis, double value) {
return TaskbarFrame_Height_double_Original(pThis, value);
}

using SystemTraySecondaryController_UpdateFrameSize_t =
void(WINAPI*)(void* pThis);
SystemTraySecondaryController_UpdateFrameSize_t
SystemTraySecondaryController_UpdateFrameSize_Original;
void WINAPI SystemTraySecondaryController_UpdateFrameSize_Hook(void* pThis) {
Wh_Log(L">");

g_inSystemTraySecondaryController_UpdateFrameSize = true;

SystemTraySecondaryController_UpdateFrameSize_Original(pThis);

g_inSystemTraySecondaryController_UpdateFrameSize = false;
}

using SystemTrayFrame_Height_t = void(WINAPI*)(void* pThis, double value);
SystemTrayFrame_Height_t SystemTrayFrame_Height_Original;
void WINAPI SystemTrayFrame_Height_Hook(void* pThis, double value) {
// Wh_Log(L">");

if (g_inSystemTraySecondaryController_UpdateFrameSize) {
// Set the secondary taskbar clock height to NaN, otherwise it may not
// match the custom taskbar height.
value = std::numeric_limits<double>::quiet_NaN();
}

SystemTrayFrame_Height_Original(pThis, value);
}

using SHAppBarMessage_t = decltype(&SHAppBarMessage);
SHAppBarMessage_t SHAppBarMessage_Original;
auto WINAPI SHAppBarMessage_Hook(DWORD dwMessage, PAPPBARDATA pData) {
Expand Down Expand Up @@ -733,6 +761,24 @@ bool HookTaskbarViewDllSymbols(HMODULE module) {
(void**)&TaskbarFrame_Height_double_Original,
(void*)TaskbarFrame_Height_double_Hook,
},
{
{
LR"(private: void __cdecl winrt::SystemTray::implementation::SystemTraySecondaryController::UpdateFrameSize(void))",
LR"(private: void __cdecl winrt::SystemTray::implementation::SystemTraySecondaryController::UpdateFrameSize(void) __ptr64)",
},
(void**)&SystemTraySecondaryController_UpdateFrameSize_Original,
(void*)SystemTraySecondaryController_UpdateFrameSize_Hook,
true,
},
{
{
LR"(public: __cdecl winrt::impl::consume_Windows_UI_Xaml_IFrameworkElement<struct winrt::SystemTray::SystemTrayFrame>::Height(double)const )",
LR"(public: __cdecl winrt::impl::consume_Windows_UI_Xaml_IFrameworkElement<struct winrt::SystemTray::SystemTrayFrame>::Height(double)const __ptr64)",
},
(void**)&SystemTrayFrame_Height_Original,
(void*)SystemTrayFrame_Height_Hook,
true,
},
};

return HookSymbols(module, symbolHooks, ARRAYSIZE(symbolHooks));
Expand Down
Loading