mirror of
https://github.com/valinet/ExplorerPatcher.git
synced 2024-11-28 01:10:55 +01:00
Start11: Center menu on screen also works when taskbar is not at the bottom
This commit is contained in:
parent
d262c41850
commit
4212e357b7
@ -10994,6 +10994,7 @@ void StartMenu_LoadSettings(BOOL bRestartIfChanged)
|
|||||||
if (InterlockedExchange64(&dwTaskbarAl, dwVal) != dwVal)
|
if (InterlockedExchange64(&dwTaskbarAl, dwVal) != dwVal)
|
||||||
{
|
{
|
||||||
StartUI_EnableRoundedCornersApply = TRUE;
|
StartUI_EnableRoundedCornersApply = TRUE;
|
||||||
|
StartDocked_DisableRecommendedSectionApply = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
@ -11259,7 +11260,7 @@ LSTATUS StartUI_RegCloseKey(HKEY hKey)
|
|||||||
return RegCloseKey(hKey);
|
return RegCloseKey(hKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
int StartUI_SetWindowRgn(HWND hWnd, HRGN hRgn, BOOL bRedraw)
|
int Start_SetWindowRgn(HWND hWnd, HRGN hRgn, BOOL bRedraw)
|
||||||
{
|
{
|
||||||
WCHAR wszDebug[MAX_PATH];
|
WCHAR wszDebug[MAX_PATH];
|
||||||
BOOL bIsWindowVisible = FALSE;
|
BOOL bIsWindowVisible = FALSE;
|
||||||
@ -11268,7 +11269,7 @@ int StartUI_SetWindowRgn(HWND hWnd, HRGN hRgn, BOOL bRedraw)
|
|||||||
{
|
{
|
||||||
if (IsWindows11()) ShowWindow(hWnd, bIsWindowVisible ? SW_SHOW : SW_HIDE);
|
if (IsWindows11()) ShowWindow(hWnd, bIsWindowVisible ? SW_SHOW : SW_HIDE);
|
||||||
DWORD TaskbarAl = InterlockedAdd(&dwTaskbarAl, 0);
|
DWORD TaskbarAl = InterlockedAdd(&dwTaskbarAl, 0);
|
||||||
if (bIsWindowVisible && (!TaskbarAl ? StartUI_EnableRoundedCornersApply : 1))
|
if (bIsWindowVisible && (!TaskbarAl ? (dwStartShowClassicMode ? StartUI_EnableRoundedCornersApply : StartDocked_DisableRecommendedSectionApply) : 1))
|
||||||
{
|
{
|
||||||
HWND hWndTaskbar = NULL;
|
HWND hWndTaskbar = NULL;
|
||||||
if (TaskbarAl)
|
if (TaskbarAl)
|
||||||
@ -11335,16 +11336,32 @@ int StartUI_SetWindowRgn(HWND hWnd, HRGN hRgn, BOOL bRedraw)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
RECT rc;
|
RECT rc;
|
||||||
LVT_StartUI_EnableRoundedCorners(hWnd, StartUI_EnableRoundedCorners, dwPos, hWndTaskbar, &rc);
|
if (dwStartShowClassicMode)
|
||||||
if (!StartUI_EnableRoundedCorners)
|
|
||||||
{
|
{
|
||||||
StartUI_EnableRoundedCornersApply = FALSE;
|
LVT_StartUI_EnableRoundedCorners(hWnd, StartUI_EnableRoundedCorners, dwPos, hWndTaskbar, &rc);
|
||||||
|
if (!StartUI_EnableRoundedCorners)
|
||||||
|
{
|
||||||
|
StartUI_EnableRoundedCornersApply = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LVT_StartDocked_DisableRecommendedSection(hWnd, StartDocked_DisableRecommendedSection, &rc);
|
||||||
|
StartDocked_DisableRecommendedSectionApply = FALSE;
|
||||||
}
|
}
|
||||||
if (hWndTaskbar)
|
if (hWndTaskbar)
|
||||||
{
|
{
|
||||||
if (rcC.left < 5 && rcC.top > 5)
|
if (rcC.left < 5 && rcC.top > 5)
|
||||||
{
|
{
|
||||||
SetWindowPos(hWnd, NULL, mi.rcMonitor.left + (((mi.rcMonitor.right - mi.rcMonitor.left) - (rc.right - rc.left)) / 2), mi.rcMonitor.top, 0, 0, SWP_NOSIZE | SWP_FRAMECHANGED | SWP_ASYNCWINDOWPOS);
|
if (dwStartShowClassicMode)
|
||||||
|
{
|
||||||
|
SetWindowPos(hWnd, NULL, mi.rcMonitor.left + (((mi.rcMonitor.right - mi.rcMonitor.left) - (rc.right - rc.left)) / 2), mi.rcMonitor.top, 0, 0, SWP_NOSIZE | SWP_FRAMECHANGED | SWP_ASYNCWINDOWPOS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Windows 11 Start menu knows how to center itself when the taskbar is at the bottom of the screen
|
||||||
|
SetWindowPos(hWnd, NULL, mi.rcMonitor.left, mi.rcMonitor.top, 0, 0, SWP_NOSIZE | SWP_FRAMECHANGED | SWP_ASYNCWINDOWPOS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (rcC.left < 5 && rcC.top < 5 && rcC.right > rcC.bottom)
|
else if (rcC.left < 5 && rcC.top < 5 && rcC.right > rcC.bottom)
|
||||||
{
|
{
|
||||||
@ -11368,21 +11385,6 @@ int StartUI_SetWindowRgn(HWND hWnd, HRGN hRgn, BOOL bRedraw)
|
|||||||
return SetWindowRgn(hWnd, hRgn, bRedraw);
|
return SetWindowRgn(hWnd, hRgn, bRedraw);
|
||||||
}
|
}
|
||||||
|
|
||||||
int StartDocked_SetWindowRgn(HWND hWnd, HRGN hRgn, BOOL bRedraw)
|
|
||||||
{
|
|
||||||
BOOL bIsWindowVisible = FALSE;
|
|
||||||
HRESULT hr = IsThreadCoreWindowVisible(&bIsWindowVisible);
|
|
||||||
if (SUCCEEDED(hr))
|
|
||||||
{
|
|
||||||
if (bIsWindowVisible && StartUI_EnableRoundedCornersApply)
|
|
||||||
{
|
|
||||||
LVT_StartDocked_DisableRecommendedSection(hWnd, StartDocked_DisableRecommendedSection);
|
|
||||||
StartDocked_DisableRecommendedSectionApply = FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return SetWindowRgn(hWnd, hRgn, bRedraw);
|
|
||||||
}
|
|
||||||
|
|
||||||
int WINAPI SetupMessage(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType)
|
int WINAPI SetupMessage(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
@ -11810,7 +11812,7 @@ void InjectStartMenu()
|
|||||||
hStartUI = GetModuleHandleW(L"StartUI.dll");
|
hStartUI = GetModuleHandleW(L"StartUI.dll");
|
||||||
|
|
||||||
// Fixes hang when Start menu closes
|
// Fixes hang when Start menu closes
|
||||||
VnPatchDelayIAT(hStartUI, "ext-ms-win-ntuser-draw-l1-1-0.dll", "SetWindowRgn", StartUI_SetWindowRgn);
|
VnPatchDelayIAT(hStartUI, "ext-ms-win-ntuser-draw-l1-1-0.dll", "SetWindowRgn", Start_SetWindowRgn);
|
||||||
|
|
||||||
if (IsWindows11())
|
if (IsWindows11())
|
||||||
{
|
{
|
||||||
@ -11840,7 +11842,7 @@ void InjectStartMenu()
|
|||||||
LoadLibraryW(L"StartDocked.dll");
|
LoadLibraryW(L"StartDocked.dll");
|
||||||
hStartDocked = GetModuleHandleW(L"StartDocked.dll");
|
hStartDocked = GetModuleHandleW(L"StartDocked.dll");
|
||||||
|
|
||||||
VnPatchDelayIAT(hStartDocked, "ext-ms-win-ntuser-draw-l1-1-0.dll", "SetWindowRgn", StartDocked_SetWindowRgn);
|
VnPatchDelayIAT(hStartDocked, "ext-ms-win-ntuser-draw-l1-1-0.dll", "SetWindowRgn", Start_SetWindowRgn);
|
||||||
}
|
}
|
||||||
|
|
||||||
Setting* settings = calloc(6, sizeof(Setting));
|
Setting* settings = calloc(6, sizeof(Setting));
|
||||||
|
@ -518,12 +518,25 @@ void LVT_StartUI_EnableRoundedCorners(HWND hWnd, DWORD dwReceipe, DWORD dwPos, H
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reference: https://www.reddit.com/r/Windows11/comments/p1ksou/this_is_not_a_concept_microsoft_in_windows_11/
|
// Reference: https://www.reddit.com/r/Windows11/comments/p1ksou/this_is_not_a_concept_microsoft_in_windows_11/
|
||||||
void LVT_StartDocked_DisableRecommendedSection(HWND hWnd, BOOL bApply)
|
void LVT_StartDocked_DisableRecommendedSection(HWND hWnd, BOOL bApply, RECT* rect)
|
||||||
{
|
{
|
||||||
WCHAR wszDebug[MAX_PATH];
|
WCHAR wszDebug[MAX_PATH];
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
|
|
||||||
Windows_UI_Xaml_IDependencyObject* pRootDependencyObject = NULL;
|
Windows_UI_Xaml_IDependencyObject* pRootDependencyObject = NULL;
|
||||||
|
Windows_UI_Xaml_Controls_ICanvasStatics* pCanvasStatics = NULL;
|
||||||
|
|
||||||
|
if (SUCCEEDED(hr))
|
||||||
|
{
|
||||||
|
HSTRING_HEADER hshControlsCanvasStatics;
|
||||||
|
HSTRING hsControlsCanvasStatics = NULL;
|
||||||
|
hr = WindowsCreateStringReference(L"Windows.UI.Xaml.Controls.Canvas", 31, &hshControlsCanvasStatics, &hsControlsCanvasStatics);
|
||||||
|
if (SUCCEEDED(hr) && hsControlsCanvasStatics)
|
||||||
|
{
|
||||||
|
hr = RoGetActivationFactory(hsControlsCanvasStatics, &IID_Windows_UI_Xaml_Controls_ICanvasStatics, &pCanvasStatics);
|
||||||
|
WindowsDeleteString(hsControlsCanvasStatics);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
@ -570,6 +583,35 @@ void LVT_StartDocked_DisableRecommendedSection(HWND hWnd, BOOL bApply)
|
|||||||
Windows_UI_Xaml_IDependencyObject* pStartSizingFrame = LVT_FindChildByClassName(pRootDependencyObject, pVisualTreeHelperStatics, L"StartDocked.StartSizingFrame", NULL);
|
Windows_UI_Xaml_IDependencyObject* pStartSizingFrame = LVT_FindChildByClassName(pRootDependencyObject, pVisualTreeHelperStatics, L"StartDocked.StartSizingFrame", NULL);
|
||||||
if (pStartSizingFrame)
|
if (pStartSizingFrame)
|
||||||
{
|
{
|
||||||
|
Windows_UI_Xaml_Thickness drc;
|
||||||
|
drc.Left = 0.0; drc.Right = 0.0; drc.Top = 0.0; drc.Bottom = 0.0;
|
||||||
|
Windows_UI_Xaml_IUIElement* pIUIElement = NULL;
|
||||||
|
Windows_UI_Xaml_IFrameworkElement* pFrameworkElement = NULL;
|
||||||
|
pStartSizingFrame->lpVtbl->QueryInterface(pStartSizingFrame, &IID_Windows_UI_Xaml_IUIElement, &pIUIElement);
|
||||||
|
if (pIUIElement)
|
||||||
|
{
|
||||||
|
pCanvasStatics->lpVtbl->GetLeft(pCanvasStatics, pIUIElement, &(drc.Left));
|
||||||
|
pCanvasStatics->lpVtbl->GetTop(pCanvasStatics, pIUIElement, &(drc.Top));
|
||||||
|
}
|
||||||
|
pStartSizingFrame->lpVtbl->QueryInterface(pStartSizingFrame, &IID_Windows_UI_Xaml_IFrameworkElement, &pFrameworkElement);
|
||||||
|
if (pFrameworkElement)
|
||||||
|
{
|
||||||
|
pFrameworkElement->lpVtbl->get_ActualWidth(pFrameworkElement, &(drc.Right));
|
||||||
|
pFrameworkElement->lpVtbl->get_ActualHeight(pFrameworkElement, &(drc.Bottom));
|
||||||
|
}
|
||||||
|
UINT dpi = GetDpiForWindow(hWnd);
|
||||||
|
RECT rc;
|
||||||
|
SetRect(&rc, drc.Left, drc.Top, drc.Right, drc.Bottom);
|
||||||
|
SetRect(&rc, MulDiv(rc.left, dpi, 96), MulDiv(rc.top, dpi, 96), MulDiv(rc.right, dpi, 96), MulDiv(rc.bottom, dpi, 96));
|
||||||
|
*rect = rc;
|
||||||
|
if (pFrameworkElement)
|
||||||
|
{
|
||||||
|
pFrameworkElement->lpVtbl->Release(pFrameworkElement);
|
||||||
|
}
|
||||||
|
if (pIUIElement)
|
||||||
|
{
|
||||||
|
pIUIElement->lpVtbl->Release(pIUIElement);
|
||||||
|
}
|
||||||
Windows_UI_Xaml_IDependencyObject* pStartSizingFramePanel = LVT_FindChildByClassName(pStartSizingFrame, pVisualTreeHelperStatics, L"StartDocked.StartSizingFramePanel", NULL);
|
Windows_UI_Xaml_IDependencyObject* pStartSizingFramePanel = LVT_FindChildByClassName(pStartSizingFrame, pVisualTreeHelperStatics, L"StartDocked.StartSizingFramePanel", NULL);
|
||||||
if (pStartSizingFramePanel)
|
if (pStartSizingFramePanel)
|
||||||
{
|
{
|
||||||
@ -698,6 +740,11 @@ void LVT_StartDocked_DisableRecommendedSection(HWND hWnd, BOOL bApply)
|
|||||||
}
|
}
|
||||||
pRootDependencyObject->lpVtbl->Release(pRootDependencyObject);
|
pRootDependencyObject->lpVtbl->Release(pRootDependencyObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pCanvasStatics)
|
||||||
|
{
|
||||||
|
pCanvasStatics->lpVtbl->Release(pCanvasStatics);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT IsThreadCoreWindowVisible(BOOL* bIsVisible)
|
HRESULT IsThreadCoreWindowVisible(BOOL* bIsVisible)
|
||||||
|
@ -1024,7 +1024,7 @@ Windows_UI_Xaml_IDependencyObject* LVT_FindChildByName(Windows_UI_Xaml_IDependen
|
|||||||
|
|
||||||
void LVT_StartUI_EnableRoundedCorners(HWND, DWORD, DWORD, HWND, RECT*);
|
void LVT_StartUI_EnableRoundedCorners(HWND, DWORD, DWORD, HWND, RECT*);
|
||||||
|
|
||||||
void LVT_StartDocked_DisableRecommendedSection(HWND, BOOL);
|
void LVT_StartDocked_DisableRecommendedSection(HWND, BOOL, RECT*);
|
||||||
|
|
||||||
HRESULT IsThreadCoreWindowVisible(BOOL*);
|
HRESULT IsThreadCoreWindowVisible(BOOL*);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user