Skip to content

Commit d5c5617

Browse files
committed
[ExplorerPatcher] Fix taskbar texturing
Fixes #2094.
1 parent 58d804d commit d5c5617

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ static SIZE g_TaskbarTextureSize;
6767
static TTaskbarTile g_TaskbarTileH, g_TaskbarTileV;
6868
static RECT g_TaskbarMargins;
6969
int g_CurrentCSMTaskbar=-1, g_CurrentWSMTaskbar=-1;
70+
// ExplorerPatcher taskbar
71+
static bool g_epTaskbar = false;
7072

7173
static void FindWindowsMenu( void );
7274
static void RecreateStartButton( size_t taskbarId );
@@ -2772,6 +2774,17 @@ static void WINAPI SHFillRectClr2( HDC hdc, const RECT *pRect, COLORREF color )
27722774
g_SHFillRectClr(hdc,pRect,color);
27732775
}
27742776

2777+
static IatHookData* g_ExtTextOutWHook = nullptr;
2778+
2779+
// used by ExplorerPatcher's custom implementation of `SHFillRectClr`
2780+
static BOOL WINAPI ExtTextOutW2(HDC hdc, int X, int Y, UINT fuOptions, const RECT* lprc, LPCWSTR lpString, UINT cbCount, const INT* lpDx)
2781+
{
2782+
if (fuOptions != ETO_OPAQUE || lpString || cbCount || lpDx || !g_CurrentTaskList || !g_TaskbarTexture || GetCurrentThreadId() != g_TaskbarThreadId)
2783+
return ExtTextOutW(hdc, X, Y, fuOptions, lprc, lpString, cbCount, lpDx);
2784+
2785+
return FALSE;
2786+
}
2787+
27752788
static HRESULT STDAPICALLTYPE DrawThemeBackground2( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCRECT pRect, LPCRECT pClipRect )
27762789
{
27772790
if (g_CurrentTaskList && g_TaskbarTexture && iPartId==1 && iStateId==0 && GetCurrentThreadId()==g_TaskbarThreadId)
@@ -2956,6 +2969,15 @@ static void InitStartMenuDLL( void )
29562969
if (GetSettingBool(L"CustomTaskbar"))
29572970
{
29582971
auto module=GetModuleHandle(L"taskbar.dll");
2972+
if (!module)
2973+
{
2974+
module = GetModuleHandle(L"ep_taskbar.5.dll");
2975+
if (!module)
2976+
module = GetModuleHandle(L"ep_taskbar.2.dll");
2977+
2978+
if (module)
2979+
g_epTaskbar = true;
2980+
}
29592981
if (!module)
29602982
module=GetModuleHandle(NULL);
29612983

@@ -2975,6 +2997,10 @@ static void InitStartMenuDLL( void )
29752997
g_StretchDIBitsHook=SetIatHook(module,"gdi32.dll","StretchDIBits",StretchDIBits2);
29762998
if (!g_StretchDIBitsHook)
29772999
g_StretchDIBitsHook=SetIatHook(module,"ext-ms-win-gdi-draw-l1-1-0.dll","StretchDIBits",StretchDIBits2);
3000+
3001+
// ExplorerPatcher compatibility
3002+
if (g_epTaskbar)
3003+
g_ExtTextOutWHook = SetIatHook(module, "gdi32.dll", "ExtTextOutW", ExtTextOutW2);
29783004
}
29793005

29803006
{
@@ -3230,6 +3256,8 @@ static void CleanStartMenuDLL( void )
32303256
g_SHFillRectClrHook=NULL;
32313257
ClearIatHook(g_StretchDIBitsHook);
32323258
g_StretchDIBitsHook=NULL;
3259+
ClearIatHook(g_ExtTextOutWHook);
3260+
g_ExtTextOutWHook = NULL;
32333261

32343262
ClearIatHook(g_DrawThemeBackgroundHook);
32353263
g_DrawThemeBackgroundHook=NULL;

0 commit comments

Comments
 (0)