[ExplorerPatcher] Fix taskbar texturing

Fixes #2094.
This commit is contained in:
ge0rdi
2025-01-19 10:55:36 +01:00
parent 58d804d22a
commit d5c561720d

View File

@@ -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;