Browse Source

Implemented Windows 11 Start button orb (#436, thanks @krlvm)

pull/886/head
Valentin Radu 4 years ago
parent
commit
a2a0b22ef2
  1. 189
      ExplorerPatcher/dllmain.c
  2. 9
      ExplorerPatcher/settings.reg

189
ExplorerPatcher/dllmain.c

@ -104,7 +104,12 @@ void WINAPI Explorer_RefreshUI(int unused);
#define ORB_STYLE_WINDOWS10 0 #define ORB_STYLE_WINDOWS10 0
#define ORB_STYLE_WINDOWS11 1 #define ORB_STYLE_WINDOWS11 1
#define ORB_WINDOWS11_SEPARATOR 1 #define ORB_STYLE_TRANSPARENT 2
typedef struct _OrbInfo
{
HTHEME hTheme;
UINT dpi;
} OrbInfo;
void* P_Icon_Light_Search = NULL; void* P_Icon_Light_Search = NULL;
DWORD S_Icon_Light_Search = 0; DWORD S_Icon_Light_Search = 0;
@ -3934,11 +3939,14 @@ DWORD WindowSwitcher(DWORD unused)
#pragma region "Load Settings from registry" #pragma region "Load Settings from registry"
#define REFRESHUI_NONE 0b00
#define REFRESHUI_GLOM 0b01
#define REFRESHUI_ORB 0b10
void WINAPI LoadSettings(LPARAM lParam) void WINAPI LoadSettings(LPARAM lParam)
{ {
BOOL bIsExplorer = LOWORD(lParam); BOOL bIsExplorer = LOWORD(lParam);
BOOL bIsRefreshAllowed = HIWORD(lParam); BOOL bIsRefreshAllowed = HIWORD(lParam);
BOOL bShouldRefreshUI = FALSE; DWORD dwRefreshUIMask = REFRESHUI_NONE;
HKEY hKey = NULL; HKEY hKey = NULL;
DWORD dwSize = 0, dwTemp = 0; DWORD dwSize = 0, dwTemp = 0;
@ -4385,15 +4393,21 @@ void WINAPI LoadSettings(LPARAM lParam)
&bTaskbarAutohideOnDoubleClick, &bTaskbarAutohideOnDoubleClick,
&dwSize &dwSize
); );
dwTemp = ORB_STYLE_WINDOWS10;
dwSize = sizeof(DWORD); dwSize = sizeof(DWORD);
RegQueryValueExW( RegQueryValueExW(
hKey, hKey,
TEXT("OrbStyle"), TEXT("OrbStyle"),
0, 0,
NULL, NULL,
&dwOrbStyle, &dwTemp,
&dwSize &dwSize
); );
if (bOldTaskbar && (dwTemp != dwOrbStyle))
{
dwOrbStyle = dwTemp;
dwRefreshUIMask |= REFRESHUI_ORB;
}
dwSize = sizeof(DWORD); dwSize = sizeof(DWORD);
RegQueryValueExW( RegQueryValueExW(
hKey, hKey,
@ -4456,9 +4470,9 @@ void WINAPI LoadSettings(LPARAM lParam)
&dwTemp, &dwTemp,
&dwSize &dwSize
); );
if (dwTemp != dwTaskbarGlomLevel) if (bOldTaskbar && (dwTemp != dwTaskbarGlomLevel))
{ {
bShouldRefreshUI = TRUE; dwRefreshUIMask = REFRESHUI_GLOM;
} }
dwTaskbarGlomLevel = dwTemp; dwTaskbarGlomLevel = dwTemp;
dwTemp = MMTASKBARGLOMLEVEL_DEFAULT; dwTemp = MMTASKBARGLOMLEVEL_DEFAULT;
@ -4471,9 +4485,9 @@ void WINAPI LoadSettings(LPARAM lParam)
&dwTemp, &dwTemp,
&dwSize &dwSize
); );
if (dwTemp != dwMMTaskbarGlomLevel) if (bOldTaskbar && (dwTemp != dwMMTaskbarGlomLevel))
{ {
bShouldRefreshUI = TRUE; dwRefreshUIMask = REFRESHUI_GLOM;
} }
dwMMTaskbarGlomLevel = dwTemp; dwMMTaskbarGlomLevel = dwTemp;
RegCloseKey(hKey); RegCloseKey(hKey);
@ -4667,9 +4681,20 @@ void WINAPI LoadSettings(LPARAM lParam)
RegCloseKey(hKey); RegCloseKey(hKey);
} }
if (bIsRefreshAllowed && bShouldRefreshUI) if (bIsRefreshAllowed && dwRefreshUIMask)
{ {
Explorer_RefreshUI(0); if (dwRefreshUIMask & REFRESHUI_GLOM)
{
Explorer_RefreshUI(0);
}
if (dwRefreshUIMask & REFRESHUI_ORB)
{
#ifdef _WIN64
ToggleTaskbarAutohide();
ToggleTaskbarAutohide();
#endif
InvalidateRect(FindWindowW(L"ExplorerPatcher_GUI_" _T(EP_CLSID), NULL), NULL, FALSE);
}
} }
} }
@ -4943,7 +4968,16 @@ HRESULT explorer_SetWindowThemeHook(
return explorer_SetWindowThemeFunc(hwnd, pszSubAppName, pszSubIdList); return explorer_SetWindowThemeFunc(hwnd, pszSubAppName, pszSubIdList);
} }
HTHEME hStartOrbTheme = NULL; INT64 explorer_SetWindowCompositionAttribute(HWND hWnd, WINCOMPATTRDATA* data)
{
if (bClassicThemeMitigations)
{
return TRUE;
}
return SetWindowCompositionAttribute(hWnd, data);
}
HDPA hOrbCollection = NULL;
HRESULT explorer_DrawThemeBackground( HRESULT explorer_DrawThemeBackground(
HTHEME hTheme, HTHEME hTheme,
HDC hdc, HDC hdc,
@ -4953,42 +4987,67 @@ HRESULT explorer_DrawThemeBackground(
LPCRECT pClipRect LPCRECT pClipRect
) )
{ {
if (dwOrbStyle == ORB_STYLE_WINDOWS11 && hStartOrbTheme == hTheme) if (dwOrbStyle && hOrbCollection)
{ {
BITMAPINFO bi; for (unsigned int i = 0; i < DPA_GetPtrCount(hOrbCollection); ++i)
ZeroMemory(&bi, sizeof(BITMAPINFO)); {
bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); OrbInfo* oi = DPA_FastGetPtr(hOrbCollection, i);
bi.bmiHeader.biWidth = 1; if (oi->hTheme == hTheme)
bi.bmiHeader.biHeight = 1; {
bi.bmiHeader.biPlanes = 1; BITMAPINFO bi;
bi.bmiHeader.biBitCount = 32; ZeroMemory(&bi, sizeof(BITMAPINFO));
bi.bmiHeader.biCompression = BI_RGB; bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
RGBQUAD transparent = { 0, 0, 0, 0 }; bi.bmiHeader.biWidth = 1;
RGBQUAD color = { 0xFF, 0xFF, 0xFF, 0xFF }; bi.bmiHeader.biHeight = 1;
bi.bmiHeader.biPlanes = 1;
StretchDIBits(hdc, bi.bmiHeader.biBitCount = 32;
pRect->left, bi.bmiHeader.biCompression = BI_RGB;
pRect->top, RGBQUAD transparent = { 0, 0, 0, 0 };
pRect->right - pRect->left, RGBQUAD color = { 0xFF, 0xFF, 0xFF, 0xFF };
pRect->bottom - pRect->top,
0, 0, 1, 1, &color, &bi, if (dwOrbStyle == ORB_STYLE_WINDOWS11)
DIB_RGB_COLORS, SRCCOPY); {
StretchDIBits(hdc, UINT separator = oi->dpi / 96;
pRect->left + ((pRect->right - pRect->left) / 2) - ORB_WINDOWS11_SEPARATOR / 2, //printf(">>> SEPARATOR %p %d %d\n", oi->hTheme, oi->dpi, separator);
pRect->top,
ORB_WINDOWS11_SEPARATOR, // Background
pRect->bottom - pRect->top, StretchDIBits(hdc,
0, 0, 1, 1, &transparent, &bi, pRect->left + (separator % 2),
DIB_RGB_COLORS, SRCCOPY); pRect->top + (separator % 2),
StretchDIBits(hdc, pRect->right - pRect->left - (separator % 2),
pRect->left, pRect->bottom - pRect->top - (separator % 2),
pRect->top + ((pRect->bottom - pRect->top) / 2) - ORB_WINDOWS11_SEPARATOR / 2, 0, 0, 1, 1, &color, &bi,
pRect->right - pRect->left, DIB_RGB_COLORS, SRCCOPY);
ORB_WINDOWS11_SEPARATOR, // Middle vertical line
0, 0, 1, 1, &transparent, &bi, StretchDIBits(hdc,
DIB_RGB_COLORS, SRCCOPY); pRect->left + ((pRect->right - pRect->left) / 2) - (separator / 2),
pRect->top,
return S_OK; separator,
pRect->bottom - pRect->top,
0, 0, 1, 1, &transparent, &bi,
DIB_RGB_COLORS, SRCCOPY);
// Middle horizontal line
StretchDIBits(hdc,
pRect->left,
pRect->top + ((pRect->bottom - pRect->top) / 2) - (separator / 2),
pRect->right - pRect->left,
separator,
0, 0, 1, 1, &transparent, &bi,
DIB_RGB_COLORS, SRCCOPY);
}
else if (dwOrbStyle == ORB_STYLE_TRANSPARENT)
{
StretchDIBits(hdc,
pRect->left,
pRect->top,
pRect->right - pRect->left,
pRect->bottom - pRect->top,
0, 0, 1, 1, &transparent, &bi,
DIB_RGB_COLORS, SRCCOPY);
}
return S_OK;
}
}
} }
if (bClassicThemeMitigations) if (bClassicThemeMitigations)
{ {
@ -5037,13 +5096,24 @@ HRESULT explorer_DrawThemeBackground(
return DrawThemeBackground(hTheme, hdc, iPartId, iStateId, pRect, pClipRect); return DrawThemeBackground(hTheme, hdc, iPartId, iStateId, pRect, pClipRect);
} }
INT64 explorer_SetWindowCompositionAttribute(HWND hWnd, WINCOMPATTRDATA* data) HRESULT explorer_CloseThemeData(HTHEME hTheme)
{ {
if (bClassicThemeMitigations) HRESULT hr = CloseThemeData(hTheme);
if (SUCCEEDED(hr) && hOrbCollection)
{ {
return TRUE; for (unsigned int i = 0; i < DPA_GetPtrCount(hOrbCollection); ++i)
{
OrbInfo* oi = DPA_FastGetPtr(hOrbCollection, i);
if (oi->hTheme == hTheme)
{
//printf(">>> DELETE DPA %p %d\n", oi->hTheme, oi->dpi);
DPA_DeletePtr(hOrbCollection, i);
free(oi);
break;
}
}
} }
return SetWindowCompositionAttribute(hWnd, data); return hr;
} }
HTHEME explorer_OpenThemeDataForDpi( HTHEME explorer_OpenThemeDataForDpi(
@ -5052,12 +5122,24 @@ HTHEME explorer_OpenThemeDataForDpi(
UINT dpi UINT dpi
) )
{ {
if (dwOrbStyle == ORB_STYLE_WINDOWS11 && (*((WORD*)&(pszClassList)+1)) && !wcscmp(pszClassList, L"TaskbarPearl")) if ((*((WORD*)&(pszClassList)+1)) && !wcscmp(pszClassList, L"TaskbarPearl"))
{ {
if (!hOrbCollection)
{
hOrbCollection = DPA_Create(MAX_NUM_MONITORS);
}
HTHEME hTheme = OpenThemeDataForDpi(hwnd, pszClassList, dpi); HTHEME hTheme = OpenThemeDataForDpi(hwnd, pszClassList, dpi);
if (hTheme) if (hTheme && hOrbCollection)
{ {
hStartOrbTheme = hTheme; OrbInfo* oi = malloc(sizeof(OrbInfo));
if (oi)
{
oi->hTheme = hTheme;
oi->dpi = dpi;
//printf(">>> APPEND DPA %p %d\n", oi->hTheme, oi->dpi);
DPA_AppendPtr(hOrbCollection, oi);
}
} }
return hTheme; return hTheme;
} }
@ -6499,6 +6581,7 @@ DWORD Inject(BOOL bIsExplorer)
VnPatchIAT(hExplorer, "user32.dll", "TrackPopupMenuEx", explorer_TrackPopupMenuExHook); VnPatchIAT(hExplorer, "user32.dll", "TrackPopupMenuEx", explorer_TrackPopupMenuExHook);
VnPatchIAT(hExplorer, "uxtheme.dll", "OpenThemeDataForDpi", explorer_OpenThemeDataForDpi); VnPatchIAT(hExplorer, "uxtheme.dll", "OpenThemeDataForDpi", explorer_OpenThemeDataForDpi);
VnPatchIAT(hExplorer, "uxtheme.dll", "DrawThemeBackground", explorer_DrawThemeBackground); VnPatchIAT(hExplorer, "uxtheme.dll", "DrawThemeBackground", explorer_DrawThemeBackground);
VnPatchIAT(hExplorer, "uxtheme.dll", "CloseThemeData", explorer_CloseThemeData);
if (bClassicThemeMitigations) if (bClassicThemeMitigations)
{ {
/*explorer_SetWindowThemeFunc = SetWindowTheme; /*explorer_SetWindowThemeFunc = SetWindowTheme;

9
ExplorerPatcher/settings.reg

@ -16,11 +16,6 @@
;shell:::{05d7b0f4-2121-4eff-bf6b-ed3f69b894d9} ;shell:::{05d7b0f4-2121-4eff-bf6b-ed3f69b894d9}
;y Customize system icons in the notification area 🡕 ;y Customize system icons in the notification area 🡕
;shell:::{05d7b0f4-2121-4eff-bf6b-ed3f69b894d9}\SystemIcons ;shell:::{05d7b0f4-2121-4eff-bf6b-ed3f69b894d9}\SystemIcons
;;[HKEY_CURRENT_USER\Software\ExplorerPatcher]
;;c 2 Start button style *
;;x 0 Windows 10 (default)
;;x 1 Windows 11
;;"OrbStyle"=dword:00000000
[HKEY_CURRENT_USER\Software\ExplorerPatcher] [HKEY_CURRENT_USER\Software\ExplorerPatcher]
;c 4 Primary taskbar location on screen * ;c 4 Primary taskbar location on screen *
;x 3 Bottom (default) ;x 3 Bottom (default)
@ -54,6 +49,10 @@
"Virtualized_{D17F1E1A-5919-4427-8F89-A1A8503CA3EB}_AutoHideTaskbar"=dword:00000000 "Virtualized_{D17F1E1A-5919-4427-8F89-A1A8503CA3EB}_AutoHideTaskbar"=dword:00000000
;t The following settings only apply to the Windows 10 taskbar: ;t The following settings only apply to the Windows 10 taskbar:
[HKEY_CURRENT_USER\Software\ExplorerPatcher] [HKEY_CURRENT_USER\Software\ExplorerPatcher]
;c 2 Start button style
;x 0 Windows 10 (default)
;x 1 Windows 11
"OrbStyle"=dword:00000000
;c 3 Combine taskbar icons on primary taskbar ;c 3 Combine taskbar icons on primary taskbar
;x 0 Always combine ;x 0 Always combine
;x 1 Combine when taskbar is full ;x 1 Combine when taskbar is full

Loading…
Cancel
Save