1
0
mirror of https://github.com/valinet/ExplorerPatcher.git synced 2025-01-24 15:22:22 +01:00

StartUI: Support for full screen Start

This commit is contained in:
Valentin Radu 2022-03-01 17:34:10 +02:00
parent 8ce021a6b8
commit 39cb9f50fa
5 changed files with 280 additions and 26 deletions

View File

@ -406,6 +406,39 @@ LSTATUS GUI_Internal_RegSetValueExW(
);
return RegSetValueExW(hKey, L"StartUI_EnableRoundedCorners", 0, dwType, lpData, cbData);
}
else if (!wcscmp(lpValueName, L"Virtualized_" _T(EP_CLSID) L"_ForceStartSize"))
{
WCHAR wszPath[MAX_PATH];
GetSystemDirectoryW(wszPath, MAX_PATH);
wcscat_s(wszPath, MAX_PATH, L"\\reg.exe");
WCHAR wszArguments[MAX_PATH];
if (*(DWORD*)lpData)
{
swprintf_s(wszArguments, MAX_PATH, L"ADD \"HKCU\\Software\\Policies\\Microsoft\\Windows\\Explorer\" /V ForceStartSize /T REG_DWORD /D %d /F", *(DWORD*)lpData);
}
else
{
swprintf_s(wszArguments, MAX_PATH, L"DELETE \"HKCU\\Software\\Policies\\Microsoft\\Windows\\Explorer\" /V ForceStartSize /F");
}
SHELLEXECUTEINFO ShExecInfo = { 0 };
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = L"runas";
ShExecInfo.lpFile = wszPath;
ShExecInfo.lpParameters = wszArguments;
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_HIDE;
ShExecInfo.hInstApp = NULL;
if (ShellExecuteExW(&ShExecInfo) && ShExecInfo.hProcess)
{
WaitForSingleObject(ShExecInfo.hProcess, INFINITE);
DWORD dwExitCode = 0;
GetExitCodeProcess(ShExecInfo.hProcess, &dwExitCode);
CloseHandle(ShExecInfo.hProcess);
}
return ERROR_SUCCESS;
}
else if (!wcscmp(lpValueName, L"Virtualized_" _T(EP_CLSID) L"_DisableRoundedCorners"))
{
return RegisterDWMService(*(DWORD*)lpData, 0);
@ -605,6 +638,10 @@ LSTATUS GUI_Internal_RegQueryValueExW(
{
return RegQueryValueExW(hKey, L"StartUI_EnableRoundedCorners", lpReserved, lpType, lpData, lpcbData);
}
else if (!wcscmp(lpValueName, L"Virtualized_" _T(EP_CLSID) L"_ForceStartSize"))
{
return RegGetValueW(HKEY_CURRENT_USER, L"SOFTWARE\\Policies\\Microsoft\\Windows\\Explorer", L"ForceStartSize", RRF_RT_DWORD, NULL, lpData, lpcbData);
}
else if (!wcscmp(lpValueName, L"Virtualized_" _T(EP_CLSID) L"_DisableRoundedCorners"))
{
HANDLE h_exists = CreateEventW(NULL, FALSE, FALSE, _T(EP_DWM_EVENTNAME));

View File

@ -8997,6 +8997,7 @@ char VisibilityChangedEventArguments_GetVisible(__int64 a1)
return v3[0];
}
DWORD Start_ForceStartSize = 0;
DWORD StartMenu_maximumFreqApps = 6;
DWORD StartMenu_ShowAllApps = 0;
DWORD StartDocked_DisableRecommendedSection = FALSE;
@ -9139,6 +9140,41 @@ void StartMenu_LoadSettings(BOOL bRestartIfChanged)
dwStartShowClassicMode = dwVal;
RegCloseKey(hKey);
}
RegCreateKeyExW(
HKEY_CURRENT_USER,
L"SOFTWARE\\Policies\\Microsoft\\Windows\\Explorer",
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_READ,
NULL,
&hKey,
NULL
);
if (hKey == NULL || hKey == INVALID_HANDLE_VALUE)
{
hKey = NULL;
}
if (hKey)
{
dwSize = sizeof(DWORD);
dwVal = 0;
RegQueryValueExW(
hKey,
TEXT("ForceStartSize"),
0,
NULL,
&dwVal,
&dwSize
);
if (bRestartIfChanged && dwVal != Start_ForceStartSize)
{
exit(0);
}
Start_ForceStartSize = dwVal;
RegCloseKey(hKey);
}
}
static INT64(*StartDocked_LauncherFrame_OnVisibilityChangedFunc)(void*, INT64, void*) = NULL;
@ -9290,16 +9326,18 @@ LSTATUS StartUI_RegGetValueW(HKEY hkey, LPCWSTR lpSubKey, LPCWSTR lpValue, DWORD
int StartUI_SetWindowRgn(HWND hWnd, HRGN hRgn, BOOL bRedraw)
{
DWORD dwThisPID = GetCurrentProcessId(), dwForeignPID = 0;
GetWindowThreadProcessId(GetForegroundWindow(), &dwForeignPID);
BOOL bStartIsHiding = (!hRgn && dwThisPID != dwForeignPID);
ShowWindow(hWnd, bStartIsHiding ? SW_HIDE : SW_SHOW);
if (!bStartIsHiding && StartUI_EnableRoundedCornersApply)
BOOL bIsWindowVisible = FALSE;
HRESULT hr = IsThreadCoreWindowVisible(&bIsWindowVisible);
if (SUCCEEDED(hr))
{
LVT_StartUI_EnableRoundedCorners(hWnd, StartUI_EnableRoundedCorners);
if (!StartUI_EnableRoundedCorners)
ShowWindow(hWnd, bIsWindowVisible ? SW_SHOW : SW_HIDE);
if (bIsWindowVisible && StartUI_EnableRoundedCornersApply)
{
StartUI_EnableRoundedCornersApply = FALSE;
LVT_StartUI_EnableRoundedCorners(hWnd, StartUI_EnableRoundedCorners);
if (!StartUI_EnableRoundedCorners)
{
StartUI_EnableRoundedCornersApply = FALSE;
}
}
}
return SetWindowRgn(hWnd, hRgn, bRedraw);
@ -9307,13 +9345,15 @@ int StartUI_SetWindowRgn(HWND hWnd, HRGN hRgn, BOOL bRedraw)
int StartDocked_SetWindowRgn(HWND hWnd, HRGN hRgn, BOOL bRedraw)
{
DWORD dwThisPID = GetCurrentProcessId(), dwForeignPID = 0;
GetWindowThreadProcessId(GetForegroundWindow(), &dwForeignPID);
BOOL bStartIsHiding = (!hRgn && dwThisPID != dwForeignPID);
if (!bStartIsHiding && StartDocked_DisableRecommendedSectionApply)
BOOL bIsWindowVisible = FALSE;
HRESULT hr = IsThreadCoreWindowVisible(&bIsWindowVisible);
if (SUCCEEDED(hr))
{
LVT_StartDocked_DisableRecommendedSection(hWnd, StartDocked_DisableRecommendedSection);
StartDocked_DisableRecommendedSectionApply = FALSE;
if (bIsWindowVisible && StartUI_EnableRoundedCornersApply)
{
LVT_StartDocked_DisableRecommendedSection(hWnd, StartDocked_DisableRecommendedSection);
StartDocked_DisableRecommendedSectionApply = FALSE;
}
}
return SetWindowRgn(hWnd, hRgn, bRedraw);
}
@ -9762,7 +9802,7 @@ void InjectStartMenu()
VnPatchDelayIAT(hStartDocked, "ext-ms-win-ntuser-draw-l1-1-0.dll", "SetWindowRgn", StartDocked_SetWindowRgn);
}
Setting* settings = calloc(4, sizeof(Setting));
Setting* settings = calloc(5, sizeof(Setting));
settings[0].callback = NULL;
settings[0].data = NULL;
settings[0].hEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
@ -9787,10 +9827,16 @@ void InjectStartMenu()
settings[3].hKey = NULL;
wcscpy_s(settings[3].name, MAX_PATH, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced");
settings[3].origin = HKEY_CURRENT_USER;
settings[4].callback = StartMenu_LoadSettings;
settings[4].data = TRUE;
settings[4].hEvent = NULL;
settings[4].hKey = NULL;
wcscpy_s(settings[4].name, MAX_PATH, L"SOFTWARE\\Policies\\Microsoft\\Windows\\Explorer");
settings[4].origin = HKEY_CURRENT_USER;
SettingsChangeParameters* params = calloc(1, sizeof(SettingsChangeParameters));
params->settings = settings;
params->size = 4;
params->size = 5;
CreateThread(
0,
0,

View File

@ -157,6 +157,47 @@ void LVT_StartUI_EnableRoundedCorners(HWND hWnd, BOOL bApply)
Windows_UI_Xaml_IDependencyObject* pStartSizingFrame = LVT_FindChildByClassName(pRootDependencyObject, pVisualTreeHelperStatics, L"StartUI.StartSizingFrame", NULL);
if (pStartSizingFrame)
{
BOOL bApplyPadding = bApply;
if (bApply)
{
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));
HMONITOR hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTOPRIMARY);
MONITORINFO mi;
ZeroMemory(&mi, sizeof(MONITORINFO));
mi.cbSize = sizeof(MONITORINFO);
GetMonitorInfoW(hMonitor, &mi);
//swprintf(wszDebug, MAX_PATH, L"RECT %d %d %d %d - %d %d %d %d\n", rc.left, rc.top, rc.right, rc.bottom, 0, 0, mi.rcWork.right - mi.rcWork.left, mi.rcWork.bottom - mi.rcWork.top);
//OutputDebugStringW(wszDebug);
bApplyPadding = !(rc.left == 0 && rc.top == 0 && abs(mi.rcWork.right - mi.rcWork.left - rc.right) < 5 && abs(mi.rcWork.bottom - mi.rcWork.top - rc.bottom) < 5);
if (pFrameworkElement)
{
pFrameworkElement->lpVtbl->Release(pFrameworkElement);
}
if (pIUIElement)
{
pIUIElement->lpVtbl->Release(pIUIElement);
}
}
Windows_UI_Xaml_IDependencyObject* pStartSizingFramePanel = LVT_FindChildByClassName(pStartSizingFrame, pVisualTreeHelperStatics, L"StartUI.StartSizingFramePanel", NULL);
if (pStartSizingFramePanel)
{
@ -192,7 +233,7 @@ void LVT_StartUI_EnableRoundedCorners(HWND hWnd, BOOL bApply)
if (pIBorder)
{
Windows_UI_Xaml_Thickness th;
th.Left = (bApply ? 10.0 : 0.0);
th.Left = (bApplyPadding ? 10.0 : 0.0);
th.Bottom = th.Left;
th.Right = th.Left;
th.Top = th.Left;
@ -567,4 +608,39 @@ void LVT_StartDocked_DisableRecommendedSection(HWND hWnd, BOOL bApply)
}
pRootDependencyObject->lpVtbl->Release(pRootDependencyObject);
}
}
}
HRESULT IsThreadCoreWindowVisible(BOOL* bIsVisible)
{
HRESULT hr = S_OK;
if (SUCCEEDED(hr))
{
HSTRING_HEADER hshWindowStatics;
HSTRING hsWindowStatics = NULL;
hr = WindowsCreateStringReference(L"Windows.UI.Xaml.Window", 22, &hshWindowStatics, &hsWindowStatics);
if (SUCCEEDED(hr) && hsWindowStatics)
{
Windows_UI_Xaml_IWindowStatics* pWindowStatics = NULL;
hr = RoGetActivationFactory(hsWindowStatics, &IID_Windows_UI_Xaml_IWindowStatics, &pWindowStatics);
if (SUCCEEDED(hr))
{
Windows_UI_Xaml_IWindow* pWindow = NULL;
hr = pWindowStatics->lpVtbl->get_Current(pWindowStatics, &pWindow);
if (SUCCEEDED(hr))
{
Windows_UI_Xaml_Core_ICoreWindow* pCoreWindow = NULL;
hr = pWindow->lpVtbl->get_CoreWindow(pWindow, &pCoreWindow);
if (SUCCEEDED(hr))
{
hr = pCoreWindow->lpVtbl->get_Visible(pCoreWindow, bIsVisible);
pCoreWindow->lpVtbl->Release(pCoreWindow);
}
pWindow->lpVtbl->Release(pWindow);
}
pWindowStatics->lpVtbl->Release(pWindowStatics);
}
WindowsDeleteString(hsWindowStatics);
}
}
return hr;
}

View File

@ -79,6 +79,88 @@ interface Windows_UI_Xaml_IWindowStatics // : IInspectable
};
#pragma endregion
#pragma region "Windows.UI.Xaml.Core.CoreWindow"
typedef interface Windows_UI_Xaml_Core_ICoreWindow Windows_UI_Xaml_Core_ICoreWindow;
typedef struct Windows_UI_Xaml_Core_ICoreWindow_Vtbl
{
BEGIN_INTERFACE
HRESULT(STDMETHODCALLTYPE* QueryInterface)(
__RPC__in Windows_UI_Xaml_Core_ICoreWindow* This,
/* [in] */ __RPC__in REFIID riid,
/* [annotation][iid_is][out] */
_COM_Outptr_ void** ppvObject);
ULONG(STDMETHODCALLTYPE* AddRef)(
__RPC__in Windows_UI_Xaml_Core_ICoreWindow* This);
ULONG(STDMETHODCALLTYPE* Release)(
__RPC__in Windows_UI_Xaml_Core_ICoreWindow* This);
HRESULT(STDMETHODCALLTYPE* GetIids)(
__RPC__in Windows_UI_Xaml_Core_ICoreWindow* This,
/* [out] */ __RPC__out ULONG* iidCount,
/* [size_is][size_is][out] */ __RPC__deref_out_ecount_full_opt(*iidCount) IID** iids);
HRESULT(STDMETHODCALLTYPE* GetRuntimeClassName)(
__RPC__in Windows_UI_Xaml_Core_ICoreWindow* This,
/* [out] */ __RPC__deref_out_opt HSTRING* className);
HRESULT(STDMETHODCALLTYPE* GetTrustLevel)(
__RPC__in Windows_UI_Xaml_Core_ICoreWindow* This,
/* [out] */ __RPC__out TrustLevel* trustLevel);
HRESULT(STDMETHODCALLTYPE* get_AutomationHostProvider)(
__RPC__in Windows_UI_Xaml_Core_ICoreWindow* This);
HRESULT(STDMETHODCALLTYPE* get_Bounds)(
__RPC__in Windows_UI_Xaml_Core_ICoreWindow* This,
/* [out] */ __RPC__out RECT* value);
HRESULT(STDMETHODCALLTYPE* get_CustomProperties)(
__RPC__in Windows_UI_Xaml_Core_ICoreWindow* This);
HRESULT(STDMETHODCALLTYPE* get_Dispatcher)(
__RPC__in Windows_UI_Xaml_Core_ICoreWindow* This);
HRESULT(STDMETHODCALLTYPE* get_FlowDirection)(
__RPC__in Windows_UI_Xaml_Core_ICoreWindow* This);
HRESULT(STDMETHODCALLTYPE* put_FlowDirection)(
__RPC__in Windows_UI_Xaml_Core_ICoreWindow* This);
HRESULT(STDMETHODCALLTYPE* get_IsInputEnabled)(
__RPC__in Windows_UI_Xaml_Core_ICoreWindow* This);
HRESULT(STDMETHODCALLTYPE* put_IsInputEnabled)(
__RPC__in Windows_UI_Xaml_Core_ICoreWindow* This);
HRESULT(STDMETHODCALLTYPE* get_PointerCursor)(
__RPC__in Windows_UI_Xaml_Core_ICoreWindow* This);
HRESULT(STDMETHODCALLTYPE* put_PointerCursor)(
__RPC__in Windows_UI_Xaml_Core_ICoreWindow* This);
HRESULT(STDMETHODCALLTYPE* get_PointerPosition)(
__RPC__in Windows_UI_Xaml_Core_ICoreWindow* This);
HRESULT(STDMETHODCALLTYPE* get_Visible)(
__RPC__in Windows_UI_Xaml_Core_ICoreWindow* This,
/* [out] */ __RPC__out BOOL* value);
// ...
END_INTERFACE
} Windows_UI_Xaml_Core_ICoreWindow_Vtbl;
interface Windows_UI_Xaml_Core_ICoreWindow // : IInspectable
{
CONST_VTBL struct Windows_UI_Xaml_Core_ICoreWindow_Vtbl* lpVtbl;
};
#pragma endregion
#pragma region "Windows.UI.Xaml.IWindow"
typedef interface Windows_UI_Xaml_IWindow Windows_UI_Xaml_IWindow;
@ -114,18 +196,24 @@ typedef struct Windows_UI_Xaml_IWindow_Vtbl
HRESULT(STDMETHODCALLTYPE* get_Bounds)(
__RPC__in Windows_UI_Xaml_IWindow* This,
/* [out] */ __RPC__out RECT* value
);
/* [out] */ __RPC__out RECT* value);
HRESULT(STDMETHODCALLTYPE* get_Visible)(
__RPC__in Windows_UI_Xaml_IWindow* This,
/* [out] */ __RPC__out BOOL* value
);
/* [out] */ __RPC__out BOOL* value);
HRESULT(STDMETHODCALLTYPE* get_Content)(
__RPC__in Windows_UI_Xaml_IWindow* This,
/* [out] */ __RPC__out IInspectable** value
);
/* [out] */ __RPC__out IInspectable** value);
HRESULT(STDMETHODCALLTYPE* put_Content)(
__RPC__in Windows_UI_Xaml_IWindow* This);
HRESULT(STDMETHODCALLTYPE* get_CoreWindow)(
__RPC__in Windows_UI_Xaml_IWindow* This,
/* [out] */ __RPC__out Windows_UI_Xaml_Core_ICoreWindow** value);
// ...
END_INTERFACE
} Windows_UI_Xaml_IWindow_Vtbl;
@ -932,4 +1020,6 @@ Windows_UI_Xaml_IDependencyObject* LVT_FindChildByName(Windows_UI_Xaml_IDependen
void LVT_StartUI_EnableRoundedCorners(HWND, BOOL);
void LVT_StartDocked_DisableRecommendedSection(HWND, BOOL);
#endif
HRESULT IsThreadCoreWindowVisible(BOOL*);
#endif

View File

@ -230,7 +230,12 @@
[HKEY_CURRENT_USER\Software\ExplorerPatcher]
;b Enable rounded corners
;"Virtualized_{D17F1E1A-5919-4427-8F89-A1A8503CA3EB}_StartUI_EnableRoundedCorners"=dword:00000000
[HKEY_CURRENT_USER\Software\ExplorerPatcher]
;c 3 Display mode
;x 0 Default
;x 1 Start menu
;x 2 Full screen Start
;"Virtualized_{D17F1E1A-5919-4427-8F89-A1A8503CA3EB}_ForceStartSize"=dword:00000000
;T Window switcher