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 on top for Windows 11 v1.0.3 #1112

Merged
merged 1 commit into from
Oct 19, 2024
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
68 changes: 61 additions & 7 deletions mods/taskbar-on-top.wh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// @id taskbar-on-top
// @name Taskbar on top for Windows 11
// @description Moves the Windows 11 taskbar to the top of the screen
// @version 1.0.2
// @version 1.0.3
// @author m417z
// @github https://github.com/m417z
// @twitter https://twitter.com/m417z
Expand Down Expand Up @@ -292,12 +292,7 @@ void WINAPI TrayUI_MakeStuckRect_Hook(void* pThis,

TrayUI_MakeStuckRect_Original(pThis, rect, param2, param3, taskbarPos);

// taskbarPos:
// 0: left
// 1: top
// 2: right
// 3: bottom
if (taskbarPos != 3) {
if (taskbarPos != ABE_BOTTOM) {
return;
}

Expand Down Expand Up @@ -325,6 +320,39 @@ void WINAPI TrayUI_MakeStuckRect_Hook(void* pThis,
}
}

using TrayUI_GetStuckInfo_t = void(WINAPI*)(void* pThis,
RECT* rect,
DWORD* taskbarPos);
TrayUI_GetStuckInfo_t TrayUI_GetStuckInfo_Original;
void WINAPI TrayUI_GetStuckInfo_Hook(void* pThis,
RECT* rect,
DWORD* taskbarPos) {
Wh_Log(L">");

TrayUI_GetStuckInfo_Original(pThis, rect, taskbarPos);

*taskbarPos = ABE_TOP;
}

void TaskbarWndProcPreProcess(HWND hWnd,
UINT Msg,
WPARAM* wParam,
LPARAM* lParam) {
switch (Msg) {
case 0x5C3: {
// The taskbar location that affects the jump list animations.
if (*wParam == ABE_BOTTOM) {
HMONITOR monitor = (HMONITOR)lParam;
if (GetTaskbarLocationForMonitor(monitor) ==
TaskbarLocation::top) {
*wParam = ABE_TOP;
}
}
break;
}
}
}

LRESULT TaskbarWndProcPostProcess(HWND hWnd,
UINT Msg,
WPARAM wParam,
Expand Down Expand Up @@ -409,6 +437,8 @@ LRESULT WINAPI TrayUI_WndProc_Hook(void* pThis,
bool* flag) {
g_hookCallCounter++;

TaskbarWndProcPreProcess(hWnd, Msg, &wParam, &lParam);

LRESULT ret =
TrayUI_WndProc_Original(pThis, hWnd, Msg, wParam, lParam, flag);

Expand All @@ -429,6 +459,8 @@ LRESULT WINAPI CSecondaryTray_v_WndProc_Hook(void* pThis,
LPARAM lParam) {
g_hookCallCounter++;

TaskbarWndProcPreProcess(hWnd, Msg, &wParam, &lParam);

LRESULT ret =
CSecondaryTray_v_WndProc_Original(pThis, hWnd, Msg, wParam, lParam);

Expand Down Expand Up @@ -1208,6 +1240,21 @@ void ApplySettings() {
SendMessage(hTaskbarWnd, WM_SETTINGCHANGE, SPI_SETLOGICALDPIOVERRIDE, 0);

g_applyingSettings = false;

// Update the taskbar location that affects the jump list animations.
auto monitorEnumProc = [hTaskbarWnd](HMONITOR hMonitor) -> BOOL {
PostMessage(hTaskbarWnd, 0x5C3, ABE_BOTTOM, (WPARAM)hMonitor);
return TRUE;
};

EnumDisplayMonitors(
nullptr, nullptr,
[](HMONITOR hMonitor, HDC hdc, LPRECT lprcMonitor,
LPARAM dwData) -> BOOL {
auto& proc = *reinterpret_cast<decltype(monitorEnumProc)*>(dwData);
return proc(hMonitor);
},
reinterpret_cast<LPARAM>(&monitorEnumProc));
}

bool GetTaskbarViewDllPath(WCHAR path[MAX_PATH]) {
Expand Down Expand Up @@ -1346,6 +1393,13 @@ bool HookTaskbarDllSymbols() {
(void**)&TrayUI_MakeStuckRect_Original,
(void*)TrayUI_MakeStuckRect_Hook,
},
{
{
LR"(public: virtual void __cdecl TrayUI::GetStuckInfo(struct tagRECT *,unsigned int *))",
},
(void**)&TrayUI_GetStuckInfo_Original,
(void*)TrayUI_GetStuckInfo_Hook,
},
{
{
LR"(public: virtual __int64 __cdecl TrayUI::WndProc(struct HWND__ *,unsigned int,unsigned __int64,__int64,bool *))",
Expand Down