From d5c561720d9e8c997b966cd997681e4726f476d9 Mon Sep 17 00:00:00 2001 From: ge0rdi Date: Sun, 19 Jan 2025 10:55:36 +0100 Subject: [PATCH 1/3] [ExplorerPatcher] Fix taskbar texturing Fixes #2094. --- Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp | 28 +++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp b/Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp index 7cf742a2c..a1f55e333 100644 --- a/Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp +++ b/Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp @@ -67,6 +67,8 @@ static SIZE g_TaskbarTextureSize; static TTaskbarTile g_TaskbarTileH, g_TaskbarTileV; static RECT g_TaskbarMargins; int g_CurrentCSMTaskbar=-1, g_CurrentWSMTaskbar=-1; +// ExplorerPatcher taskbar +static bool g_epTaskbar = false; static void FindWindowsMenu( void ); static void RecreateStartButton( size_t taskbarId ); @@ -2772,6 +2774,17 @@ static void WINAPI SHFillRectClr2( HDC hdc, const RECT *pRect, COLORREF color ) g_SHFillRectClr(hdc,pRect,color); } +static IatHookData* g_ExtTextOutWHook = nullptr; + +// used by ExplorerPatcher's custom implementation of `SHFillRectClr` +static BOOL WINAPI ExtTextOutW2(HDC hdc, int X, int Y, UINT fuOptions, const RECT* lprc, LPCWSTR lpString, UINT cbCount, const INT* lpDx) +{ + if (fuOptions != ETO_OPAQUE || lpString || cbCount || lpDx || !g_CurrentTaskList || !g_TaskbarTexture || GetCurrentThreadId() != g_TaskbarThreadId) + return ExtTextOutW(hdc, X, Y, fuOptions, lprc, lpString, cbCount, lpDx); + + return FALSE; +} + static HRESULT STDAPICALLTYPE DrawThemeBackground2( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCRECT pRect, LPCRECT pClipRect ) { if (g_CurrentTaskList && g_TaskbarTexture && iPartId==1 && iStateId==0 && GetCurrentThreadId()==g_TaskbarThreadId) @@ -2956,6 +2969,15 @@ static void InitStartMenuDLL( void ) if (GetSettingBool(L"CustomTaskbar")) { auto module=GetModuleHandle(L"taskbar.dll"); + if (!module) + { + module = GetModuleHandle(L"ep_taskbar.5.dll"); + if (!module) + module = GetModuleHandle(L"ep_taskbar.2.dll"); + + if (module) + g_epTaskbar = true; + } if (!module) module=GetModuleHandle(NULL); @@ -2975,6 +2997,10 @@ static void InitStartMenuDLL( void ) g_StretchDIBitsHook=SetIatHook(module,"gdi32.dll","StretchDIBits",StretchDIBits2); if (!g_StretchDIBitsHook) g_StretchDIBitsHook=SetIatHook(module,"ext-ms-win-gdi-draw-l1-1-0.dll","StretchDIBits",StretchDIBits2); + + // ExplorerPatcher compatibility + if (g_epTaskbar) + g_ExtTextOutWHook = SetIatHook(module, "gdi32.dll", "ExtTextOutW", ExtTextOutW2); } { @@ -3230,6 +3256,8 @@ static void CleanStartMenuDLL( void ) g_SHFillRectClrHook=NULL; ClearIatHook(g_StretchDIBitsHook); g_StretchDIBitsHook=NULL; + ClearIatHook(g_ExtTextOutWHook); + g_ExtTextOutWHook = NULL; ClearIatHook(g_DrawThemeBackgroundHook); g_DrawThemeBackgroundHook=NULL; From 4943938d0f562d87874fcc1852f8aaba09ff378e Mon Sep 17 00:00:00 2001 From: ge0rdi Date: Sun, 19 Jan 2025 10:56:38 +0100 Subject: [PATCH 2/3] [ExplorerPatcher] Don't shift custom start button on Win11 --- Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp b/Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp index a1f55e333..a660d0c94 100644 --- a/Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp +++ b/Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp @@ -1344,7 +1344,7 @@ static void UpdateStartButtonPosition(const TaskbarInfo* taskBar, const WINDOWPO // Start button on Win11 is a bit shifted to the right // We will shift our Aero button to cover original button - if (IsWin11() && (x == info.rcMonitor.left) && (GetStartButtonType() == START_BUTTON_AERO)) + if (IsWin11() && (x == info.rcMonitor.left) && (GetStartButtonType() == START_BUTTON_AERO) && !g_epTaskbar) x += ScaleForDpi(taskBar->taskBar, 6); } From 146c27ecd2aa78ef8e712cef7642b2e19289d19f Mon Sep 17 00:00:00 2001 From: ge0rdi Date: Sun, 19 Jan 2025 11:00:31 +0100 Subject: [PATCH 3/3] Fix tray button positioning --- Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp b/Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp index a660d0c94..9f26f2284 100644 --- a/Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp +++ b/Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp @@ -3230,6 +3230,7 @@ static void RecreateStartButton( size_t taskbarId ) { RECT rc; GetWindowRect(btn,&rc); + MapWindowPoints(NULL,taskBar.taskBar,(POINT*)&rc,2); // convert to taskbar coordinates SetWindowPos(btn,HWND_TOP,rc.left,rc.top,0,0,SWP_NOSIZE|SWP_NOACTIVATE|SWP_NOZORDER); } }