mirror of
https://github.com/valinet/ExplorerPatcher.git
synced 2024-11-28 01:10:55 +01:00
Taskbar10: Improved animation performance when centering and/or EP Weather is not enabled, also fixed search box positioning on small taskbar size
This commit is contained in:
parent
35e31b91e2
commit
22d9e3c6ac
@ -1,5 +1,7 @@
|
|||||||
#include "TaskbarCenter.h"
|
#include "TaskbarCenter.h"
|
||||||
|
|
||||||
|
#include "../ep_weather_host/ep_weather_host_h.h"
|
||||||
|
|
||||||
DEFINE_GUID(POLID_TurnOffSPIAnimations, 0xD7AF00A, 0xB468, 0x4A39, 0xB0, 0x16, 0x33, 0x3E, 0x22, 0x77, 0xAB, 0xED);
|
DEFINE_GUID(POLID_TurnOffSPIAnimations, 0xD7AF00A, 0xB468, 0x4A39, 0xB0, 0x16, 0x33, 0x3E, 0x22, 0x77, 0xAB, 0xED);
|
||||||
extern int(*SHWindowsPolicy)(REFIID);
|
extern int(*SHWindowsPolicy)(REFIID);
|
||||||
extern HWND PeopleButton_LastHWND;
|
extern HWND PeopleButton_LastHWND;
|
||||||
@ -8,6 +10,7 @@ extern DWORD dwOldTaskbarAl;
|
|||||||
extern DWORD dwMMOldTaskbarAl;
|
extern DWORD dwMMOldTaskbarAl;
|
||||||
extern DWORD dwSearchboxTaskbarMode;
|
extern DWORD dwSearchboxTaskbarMode;
|
||||||
extern wchar_t* EP_TASKBAR_LENGTH_PROP_NAME;
|
extern wchar_t* EP_TASKBAR_LENGTH_PROP_NAME;
|
||||||
|
extern IEPWeather* epw;
|
||||||
#define EP_TASKBAR_LENGTH_TOO_SMALL 20
|
#define EP_TASKBAR_LENGTH_TOO_SMALL 20
|
||||||
BOOL bTaskbarCenterHasPatchedSHWindowsPolicy = FALSE;
|
BOOL bTaskbarCenterHasPatchedSHWindowsPolicy = FALSE;
|
||||||
UINT atomPeopleBand = 0;
|
UINT atomPeopleBand = 0;
|
||||||
@ -112,34 +115,42 @@ HRESULT TaskbarCenter_Center(HWND hWnd, HWND hWndTaskbar, RECT rc, BOOL bIsTaskb
|
|||||||
BOOL TaskbarCenter_GetClientRectHook(HWND hWnd, LPRECT lpRect)
|
BOOL TaskbarCenter_GetClientRectHook(HWND hWnd, LPRECT lpRect)
|
||||||
{
|
{
|
||||||
BOOL bWasCalled = FALSE;
|
BOOL bWasCalled = FALSE;
|
||||||
HWND hWndStart = NULL;
|
|
||||||
RECT rcStart;
|
|
||||||
SetRect(&rcStart, 0, 0, 0, 0);
|
|
||||||
if (!atomMSTaskListWClass) atomMSTaskListWClass = RegisterWindowMessageW(L"MSTaskListWClass");
|
if (!atomMSTaskListWClass) atomMSTaskListWClass = RegisterWindowMessageW(L"MSTaskListWClass");
|
||||||
if (GetClassWord(hWnd, GCW_ATOM) == atomMSTaskListWClass)
|
if (GetClassWord(hWnd, GCW_ATOM) == atomMSTaskListWClass)
|
||||||
{
|
{
|
||||||
if (!atomMSTaskSwWClass) atomMSTaskSwWClass = RegisterWindowMessageW(L"MSTaskSwWClass");
|
if (!atomMSTaskSwWClass) atomMSTaskSwWClass = RegisterWindowMessageW(L"MSTaskSwWClass");
|
||||||
BOOL bIsPrimaryTaskbar = (GetClassWord(GetParent(hWnd), GCW_ATOM) == atomMSTaskSwWClass);
|
HWND hwndParent = GetParent(hWnd);
|
||||||
|
BOOL bIsPrimaryTaskbar = (GetClassWord(hwndParent, GCW_ATOM) == atomMSTaskSwWClass);
|
||||||
DWORD dwSetting = (bIsPrimaryTaskbar ? dwOldTaskbarAl : dwMMOldTaskbarAl);
|
DWORD dwSetting = (bIsPrimaryTaskbar ? dwOldTaskbarAl : dwMMOldTaskbarAl);
|
||||||
|
BOOL bCenteringEnabled = TaskbarCenter_ShouldCenter(dwSetting);
|
||||||
|
if (!bCenteringEnabled && GetPropW(hWnd, EP_TASKBAR_LENGTH_PROP_NAME))
|
||||||
|
{
|
||||||
|
RemovePropW(hWnd, EP_TASKBAR_LENGTH_PROP_NAME);
|
||||||
|
}
|
||||||
|
if (!bCenteringEnabled && !epw)
|
||||||
|
{
|
||||||
|
return GetClientRect(hWnd, lpRect); // Early out
|
||||||
|
}
|
||||||
|
HWND hWndStart = NULL;
|
||||||
|
RECT rcStart = { 0, 0, 0, 0 };
|
||||||
HWND hWndTaskbar = NULL;
|
HWND hWndTaskbar = NULL;
|
||||||
if (bIsPrimaryTaskbar)
|
if (bIsPrimaryTaskbar)
|
||||||
{
|
{
|
||||||
hWndTaskbar = GetParent(GetParent(GetParent(hWnd)));
|
hWndTaskbar = GetParent(GetParent(hwndParent));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hWndTaskbar = GetParent(GetParent(hWnd));
|
hWndTaskbar = GetParent(hwndParent);
|
||||||
}
|
}
|
||||||
hWndStart = FindWindowExW(hWndTaskbar, NULL, L"Start", NULL);
|
hWndStart = FindWindowExW(hWndTaskbar, NULL, L"Start", NULL);
|
||||||
BOOL bIsTaskbarHorizontal = TaskbarCenter_IsTaskbarHorizontal(hWnd);
|
BOOL bIsTaskbarHorizontal = TaskbarCenter_IsTaskbarHorizontal(hWnd);
|
||||||
BOOL bIsWeatherAvailable = FALSE;
|
|
||||||
HWND hReBarWindow32 = NULL;
|
HWND hReBarWindow32 = NULL;
|
||||||
if (bIsPrimaryTaskbar) hReBarWindow32 = FindWindowExW(hWndTaskbar, NULL, L"ReBarWindow32", NULL);
|
if (bIsPrimaryTaskbar) hReBarWindow32 = FindWindowExW(hWndTaskbar, NULL, L"ReBarWindow32", NULL);
|
||||||
HWND hPeopleBand = NULL;
|
HWND hPeopleBand = NULL;
|
||||||
if (bIsPrimaryTaskbar) hPeopleBand = FindWindowExW(hReBarWindow32, NULL, L"PeopleBand", NULL);
|
if (bIsPrimaryTaskbar) hPeopleBand = FindWindowExW(hReBarWindow32, NULL, L"PeopleBand", NULL);
|
||||||
bIsWeatherAvailable = hPeopleBand && dwWeatherToLeft;
|
BOOL bIsWeatherAvailable = hPeopleBand && dwWeatherToLeft;
|
||||||
BOOL bWasLeftAlignedDueToSpaceConstraints = FALSE;
|
BOOL bWasLeftAlignedDueToSpaceConstraints = FALSE;
|
||||||
if (TaskbarCenter_ShouldCenter(dwSetting))
|
if (bCenteringEnabled)
|
||||||
{
|
{
|
||||||
if (hWndStart)
|
if (hWndStart)
|
||||||
{
|
{
|
||||||
@ -229,10 +240,8 @@ BOOL TaskbarCenter_GetClientRectHook(HWND hWnd, LPRECT lpRect)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RECT rcPeopleBand;
|
RECT rcPeopleBand = { 0, 0, 0, 0 };
|
||||||
SetRect(&rcPeopleBand, 0, 0, 0, 0);
|
RECT rcReBarWindow32 = { 0, 0, 0, 0 };
|
||||||
RECT rcReBarWindow32;
|
|
||||||
SetRect(&rcReBarWindow32, 0, 0, 0, 0);
|
|
||||||
if (hPeopleBand)
|
if (hPeopleBand)
|
||||||
{
|
{
|
||||||
GetClientRect(hPeopleBand, &rcPeopleBand);
|
GetClientRect(hPeopleBand, &rcPeopleBand);
|
||||||
@ -371,14 +380,7 @@ BOOL TaskbarCenter_GetClientRectHook(HWND hWnd, LPRECT lpRect)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
if (bIsPrimaryTaskbar && epw)
|
||||||
{
|
|
||||||
if (GetPropW(hWnd, EP_TASKBAR_LENGTH_PROP_NAME))
|
|
||||||
{
|
|
||||||
RemovePropW(hWnd, EP_TASKBAR_LENGTH_PROP_NAME);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (bIsPrimaryTaskbar)
|
|
||||||
{
|
{
|
||||||
BOOL bWeatherAlignment = FALSE;
|
BOOL bWeatherAlignment = FALSE;
|
||||||
if (bIsWeatherAvailable)
|
if (bIsWeatherAvailable)
|
||||||
@ -444,8 +446,7 @@ BOOL TaskbarCenter_GetClientRectHook(HWND hWnd, LPRECT lpRect)
|
|||||||
SendMessageW(hReBarWindow32, RB_GETBANDINFOW, i, &rbi);
|
SendMessageW(hReBarWindow32, RB_GETBANDINFOW, i, &rbi);
|
||||||
if (rbi.hwndChild && (GetClassWord(rbi.hwndChild, GCW_ATOM) == atomPeopleBand))
|
if (rbi.hwndChild && (GetClassWord(rbi.hwndChild, GCW_ATOM) == atomPeopleBand))
|
||||||
{
|
{
|
||||||
RECT rcpp;
|
RECT rcpp = { 0, 0, 0, 0 };
|
||||||
SetRect(&rcpp, 0, 0, 0, 0);
|
|
||||||
GetClientRect(rbi.hwndChild, &rcpp);
|
GetClientRect(rbi.hwndChild, &rcpp);
|
||||||
if (rcpp.right && rcpp.bottom)
|
if (rcpp.right && rcpp.bottom)
|
||||||
{
|
{
|
||||||
@ -462,40 +463,6 @@ BOOL TaskbarCenter_GetClientRectHook(HWND hWnd, LPRECT lpRect)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((!TaskbarCenter_ShouldCenter(dwSetting) || !TaskbarCenter_ShouldStartBeCentered(dwSetting)) && hWndStart)
|
|
||||||
{
|
|
||||||
GetWindowRect(hWndStart, &rcStart);
|
|
||||||
if (rcStart.left != 0 || rcStart.top != 0)
|
|
||||||
{
|
|
||||||
SetWindowPos(hWndStart, NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_FRAMECHANGED | SWP_ASYNCWINDOWPOS);
|
|
||||||
if (!bIsPrimaryTaskbar) InvalidateRect(hWndStart, NULL, TRUE);
|
|
||||||
RECT rcTrayButton;
|
|
||||||
GetClientRect(hWndStart, &rcTrayButton);
|
|
||||||
DWORD dwDim = bIsTaskbarHorizontal ? (rcTrayButton.right - rcTrayButton.left) : (rcTrayButton.bottom - rcTrayButton.top);
|
|
||||||
HWND hTrayButton = NULL;
|
|
||||||
wchar_t* pCn = L"TrayButton";
|
|
||||||
if (/*!IsWindows11() &&*/ dwSearchboxTaskbarMode == 2) pCn = L"TrayDummySearchControl";
|
|
||||||
while (hTrayButton = FindWindowExW(hWndTaskbar, hTrayButton, pCn, NULL))
|
|
||||||
{
|
|
||||||
if (pCn == L"TrayButton" && !IsWindowVisible(hTrayButton)) continue;
|
|
||||||
GetClientRect(hTrayButton, &rcTrayButton);
|
|
||||||
if (bIsTaskbarHorizontal)
|
|
||||||
{
|
|
||||||
MoveWindow(hTrayButton, dwDim, 0, rcTrayButton.right, rcTrayButton.bottom, TRUE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MoveWindow(hTrayButton, 0, dwDim, rcTrayButton.right, rcTrayButton.bottom, TRUE);
|
|
||||||
}
|
|
||||||
if (!bIsPrimaryTaskbar || !bIsTaskbarHorizontal) InvalidateRect(hTrayButton, NULL, TRUE);
|
|
||||||
dwDim += bIsTaskbarHorizontal ? (rcTrayButton.right - rcTrayButton.left) : (rcTrayButton.bottom - rcTrayButton.top);
|
|
||||||
if (pCn == L"TrayDummySearchControl") {
|
|
||||||
pCn = L"TrayButton";
|
|
||||||
hTrayButton = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (bWasCalled) return bWasCalled;
|
if (bWasCalled) return bWasCalled;
|
||||||
return GetClientRect(hWnd, lpRect);
|
return GetClientRect(hWnd, lpRect);
|
||||||
|
@ -777,7 +777,33 @@ HWND hWndServiceWindow = NULL;
|
|||||||
|
|
||||||
void FixUpCenteredTaskbar()
|
void FixUpCenteredTaskbar()
|
||||||
{
|
{
|
||||||
PostMessageW(FindWindowW(L"Shell_TrayWnd", NULL), 798, 0, 0); // uMsg = 0x31E in explorer!TrayUI::WndProc
|
HWND hwndPrimaryTray = FindWindowW(L"Shell_TrayWnd", NULL);
|
||||||
|
PostMessageW(hwndPrimaryTray, WM_DWMCOMPOSITIONCHANGED, 0, 0); // uMsg = 0x31E in explorer!TrayUI::WndProc
|
||||||
|
if (!TaskbarCenter_ShouldStartBeCentered(dwOldTaskbarAl) && hwndPrimaryTray)
|
||||||
|
{
|
||||||
|
HWND hwndStart = FindWindowExW(hwndPrimaryTray, NULL, L"Start", NULL);
|
||||||
|
SetWindowPos(hwndStart, NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_FRAMECHANGED | SWP_ASYNCWINDOWPOS);
|
||||||
|
InvalidateRect(hwndStart, NULL, TRUE);
|
||||||
|
}
|
||||||
|
if (!TaskbarCenter_ShouldStartBeCentered(dwMMOldTaskbarAl))
|
||||||
|
{
|
||||||
|
HWND hWnd = NULL;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
hWnd = FindWindowEx(
|
||||||
|
NULL,
|
||||||
|
hWnd,
|
||||||
|
L"Shell_SecondaryTrayWnd",
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
if (hWnd)
|
||||||
|
{
|
||||||
|
HWND hwndStart = FindWindowExW(hWnd, NULL, L"Start", NULL);
|
||||||
|
SetWindowPos(hwndStart, NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_FRAMECHANGED | SWP_ASYNCWINDOWPOS);
|
||||||
|
InvalidateRect(hwndStart, NULL, TRUE);
|
||||||
|
}
|
||||||
|
} while (hWnd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define EP_SERVICE_WINDOW_CLASS_NAME L"EP_Service_Window_" _T(EP_CLSID)
|
#define EP_SERVICE_WINDOW_CLASS_NAME L"EP_Service_Window_" _T(EP_CLSID)
|
||||||
@ -7486,15 +7512,21 @@ void WINAPI Explorer_RefreshUI(int src)
|
|||||||
}
|
}
|
||||||
if (hKey)
|
if (hKey)
|
||||||
{
|
{
|
||||||
|
dwTemp = 0;
|
||||||
dwSize = sizeof(DWORD);
|
dwSize = sizeof(DWORD);
|
||||||
RegQueryValueExW(
|
RegQueryValueExW(
|
||||||
hKey,
|
hKey,
|
||||||
TEXT("TaskbarSmallIcons"),
|
TEXT("TaskbarSmallIcons"),
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
&dwTaskbarSmallIcons,
|
&dwTemp,
|
||||||
&dwSize
|
&dwSize
|
||||||
);
|
);
|
||||||
|
if (dwTemp != dwTaskbarSmallIcons)
|
||||||
|
{
|
||||||
|
dwTaskbarSmallIcons = dwTemp;
|
||||||
|
UpdateSearchBox();
|
||||||
|
}
|
||||||
dwTemp = 0;
|
dwTemp = 0;
|
||||||
dwSize = sizeof(DWORD);
|
dwSize = sizeof(DWORD);
|
||||||
RegQueryValueExW(
|
RegQueryValueExW(
|
||||||
|
Loading…
Reference in New Issue
Block a user