Skip to content

Commit f3feb32

Browse files
authored
Merge branch 'master' into feature/classic-explorer-dark-mode
2 parents a62d2ec + e1fe220 commit f3feb32

7 files changed

Lines changed: 130 additions & 12 deletions

File tree

‎Src/Lib/SettingsUIHelper.cpp‎

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,8 @@ void EnableSettingsTreeAccessibility( HWND tree )
140140
server->Release();
141141
}
142142

143-
void ClearSettingsTreeItemAccessibility( HWND tree )
143+
static void ClearSettingsTreeItemAccessibilityImpl( IAccPropServices *props, HWND tree )
144144
{
145-
CComPtr<IAccPropServices> props;
146-
if (FAILED(CoCreateInstance(CLSID_SettingsAccPropServices,NULL,CLSCTX_INPROC_SERVER,IID_PPV_ARGS(&props)))) return;
147145
MSAAPROPID properties[]={PROPID_SettingsAccState,PROPID_SettingsAccName,PROPID_SettingsAccRole};
148146
for (HTREEITEM item=TreeView_GetRoot(tree);item;)
149147
{
@@ -159,6 +157,27 @@ void ClearSettingsTreeItemAccessibility( HWND tree )
159157
}
160158
}
161159

160+
void ClearSettingsTreeItemAccessibility( HWND tree )
161+
{
162+
if (!tree || !IsWindow(tree)) return;
163+
CComPtr<IAccPropServices> props;
164+
if (FAILED(CoCreateInstance(CLSID_SettingsAccPropServices,NULL,CLSCTX_INPROC_SERVER,IID_PPV_ARGS(&props)))) return;
165+
ClearSettingsTreeItemAccessibilityImpl(props,tree);
166+
}
167+
168+
void ClearSettingsTreeAccessibility( HWND tree )
169+
{
170+
if (!tree || !IsWindow(tree)) return;
171+
CComPtr<IAccPropServices> props;
172+
if (FAILED(CoCreateInstance(CLSID_SettingsAccPropServices,NULL,CLSCTX_INPROC_SERVER,IID_PPV_ARGS(&props)))) return;
173+
174+
// Release all per-item servers while their accessibility IDs can still be
175+
// resolved, then remove the container server and the tree-level name.
176+
ClearSettingsTreeItemAccessibilityImpl(props,tree);
177+
MSAAPROPID properties[]={PROPID_SettingsAccState,PROPID_SettingsAccName,PROPID_SettingsAccRole};
178+
props->ClearHwndProps(tree,OBJID_CLIENT,CHILDID_SELF,properties,_countof(properties));
179+
}
180+
162181
void SetControlAccessibleName( HWND control, const wchar_t *name )
163182
{
164183
CComPtr<IAccPropServices> props;
@@ -2778,6 +2797,7 @@ LRESULT CTreeSettingsDlg::OnInitDialog( UINT uMsg, WPARAM wParam, LPARAM lParam,
27782797

27792798
LRESULT CTreeSettingsDlg::OnDestroy( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled )
27802799
{
2800+
ClearSettingsTreeAccessibility(m_Tree);
27812801
DestroyIcon(m_PlayIcon);
27822802
bHandled=FALSE;
27832803
m_EditMode=EDIT_NONE;

‎Src/Lib/SettingsUIHelper.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ struct CSetting;
1919
// by Open-Shell's existing image list.
2020
void EnableSettingsTreeAccessibility( HWND tree );
2121
void ClearSettingsTreeItemAccessibility( HWND tree );
22+
void ClearSettingsTreeAccessibility( HWND tree );
2223
void SetControlAccessibleName( HWND control, const wchar_t *name );
2324
void SetSettingsTreeAccessibleName( HWND tree, const wchar_t *name );
2425
void SetSettingsTreeItemAccessibleName( HWND tree, HTREEITEM item, const wchar_t *name );

‎Src/Setup/Setup.cpp‎

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,69 @@ struct Chunk
4747
int start1, start2, len;
4848
};
4949

50+
static bool IsExplorerShellRunning( void )
51+
{
52+
HWND shellWindow=GetShellWindow();
53+
if (!shellWindow)
54+
return false;
55+
56+
DWORD shellProcessId=0;
57+
GetWindowThreadProcessId(shellWindow,&shellProcessId);
58+
if (!shellProcessId)
59+
return false;
60+
61+
DWORD currentSession=0;
62+
DWORD shellSession=0;
63+
if (!ProcessIdToSessionId(GetCurrentProcessId(),&currentSession) ||
64+
!ProcessIdToSessionId(shellProcessId,&shellSession) ||
65+
currentSession!=shellSession)
66+
{
67+
return false;
68+
}
69+
70+
HANDLE process=OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION,FALSE,shellProcessId);
71+
if (!process)
72+
return false;
73+
74+
wchar_t path[_MAX_PATH];
75+
DWORD pathSize=_countof(path);
76+
bool isExplorer=false;
77+
if (QueryFullProcessImageName(process,0,path,&pathSize))
78+
isExplorer=_wcsicmp(PathFindFileName(path),L"explorer.exe")==0;
79+
80+
CloseHandle(process);
81+
return isExplorer;
82+
}
83+
84+
static void RestoreExplorerShellIfNeeded( bool wasRunning )
85+
{
86+
if (!wasRunning)
87+
return;
88+
89+
// Restart Manager normally brings Explorer back before msiexec exits.
90+
// Give it a short grace period before applying our fallback so we don't
91+
// race a normal restart or create an extra Explorer process.
92+
for (int i=0;i<50;i++)
93+
{
94+
if (IsExplorerShellRunning())
95+
return;
96+
Sleep(100);
97+
}
98+
99+
wchar_t explorerPath[_MAX_PATH];
100+
UINT len=GetWindowsDirectory(explorerPath,_countof(explorerPath));
101+
if (!len || len>=_countof(explorerPath) || !PathAppend(explorerPath,L"explorer.exe"))
102+
return;
103+
104+
STARTUPINFO startupInfo={sizeof(startupInfo)};
105+
PROCESS_INFORMATION processInfo={};
106+
if (CreateProcess(explorerPath,NULL,NULL,NULL,FALSE,0,NULL,NULL,&startupInfo,&processInfo))
107+
{
108+
CloseHandle(processInfo.hThread);
109+
CloseHandle(processInfo.hProcess);
110+
}
111+
}
112+
50113
static void WriteFileXOR( HANDLE hFile, const unsigned char *buf, int size )
51114
{
52115
if (size>0)
@@ -409,6 +472,11 @@ int APIENTRY wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCm
409472
if (extractType == ARM64)
410473
Wow64DisableWow64FsRedirection(&wow64FsRedirVal);
411474

475+
// Remember whether this interactive session had the Explorer desktop shell.
476+
// If Restart Manager closes it during MSI processing but fails to bring it
477+
// back, restore only the shell that was present before setup started.
478+
const bool explorerWasRunning=IsExplorerShellRunning();
479+
412480
// start the installer
413481
STARTUPINFO startupInfo={sizeof(startupInfo)};
414482
PROCESS_INFORMATION processInfo;
@@ -438,6 +506,12 @@ int APIENTRY wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCm
438506
GetExitCodeProcess(processInfo.hProcess,&code);
439507
CloseHandle(processInfo.hProcess);
440508
DeleteFile(msiName);
509+
510+
// Only repair the shell after a successful transaction. Reboot-required
511+
// outcomes deliberately keep Windows Installer in control of recovery.
512+
if (code==ERROR_SUCCESS)
513+
RestoreExplorerShellIfNeeded(explorerWasRunning);
514+
441515
return code;
442516
}
443517
}

‎Src/StartMenu/StartMenuDLL/MenuContainer.cpp‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2537,10 +2537,11 @@ void CMenuContainer::InitItems( void )
25372537
}
25382538
}
25392539

2540-
if (m_Items.empty() && m_Path1[0] && m_pDropFolder[0])
2540+
if (!m_bSubMenu && m_Items.empty() && m_Path1[0] && m_pDropFolder[0])
25412541
{
2542-
// add (Empty) item to the empty submenus
2543-
MenuItem item(m_bSubMenu?MENU_EMPTY:MENU_EMPTY_TOP);
2542+
// Keep the top-level drop target placeholder. Submenus defer their
2543+
// empty-state decision until after custom/standard items are appended.
2544+
MenuItem item(MENU_EMPTY_TOP);
25442545
item.name=FindTranslation(L"Menu.Empty",L"(Empty)");
25452546
m_Items.push_back(item);
25462547
}

‎Src/StartMenu/StartMenuDLL/MenuPaint.cpp‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,13 +1185,23 @@ void CMenuContainer::CreateBackground( int width1, int width2, int height1, int
11851185

11861186
if (opacity!=MenuSkin::OPACITY_SOLID && !bMask)
11871187
{
1188-
// set to opaque
1188+
// set the visible part to opaque. BitBlt/AlphaBlend above clip to
1189+
// the destination bitmap automatically, but this direct pixel pass
1190+
// must do the same before forming a pointer into the DIB.
11891191
SelectObject(hdc,bmp0); // deselect m_Bitmap so all the GDI operations get flushed
1190-
unsigned int *bits2=bits+pos.y*totalWidth+pos.x;
1191-
alpha<<=24;
1192-
for (int y=0;y<s_Skin.User_image_size;y++,bits2+=totalWidth)
1193-
for (int x=0;x<s_Skin.User_image_size;x++)
1194-
bits2[x]=alpha|(bits2[x]&0xFFFFFF);
1192+
RECT imageRect={pos.x,pos.y,pos.x+s_Skin.User_image_size,pos.y+s_Skin.User_image_size};
1193+
RECT bitmapRect={0,0,totalWidth,totalHeight};
1194+
RECT clippedRect;
1195+
if (IntersectRect(&clippedRect,&imageRect,&bitmapRect))
1196+
{
1197+
unsigned int opaqueAlpha=alpha<<24;
1198+
for (int y=clippedRect.top;y<clippedRect.bottom;y++)
1199+
{
1200+
unsigned int *row=bits+y*totalWidth+clippedRect.left;
1201+
for (int x=clippedRect.left;x<clippedRect.right;x++,row++)
1202+
*row=opaqueAlpha|(*row&0xFFFFFF);
1203+
}
1204+
}
11951205
SelectObject(hdc,m_Bitmap);
11961206
}
11971207

‎Src/StartMenu/StartMenuDLL/SettingsUI.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ LRESULT CSkinSettingsDlg::OnInitDialog( UINT uMsg, WPARAM wParam, LPARAM lParam,
285285

286286
LRESULT CSkinSettingsDlg::OnDestroy( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled )
287287
{
288+
ClearSettingsTreeAccessibility(m_Tree);
288289
m_EditMode=SKIN_OPTION_NONE;
289290
bHandled=FALSE;
290291
return 0;

‎Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4229,6 +4229,17 @@ if (!g_bTrimHooks)
42294229
}
42304230
else if (bShowWinX)
42314231
{
4232+
// Win+X is shown asynchronously on Windows 11. Cancel any pending
4233+
// hover-open timer first, otherwise it can open the configured
4234+
// hover menu a moment later and dismiss Win+X again.
4235+
if (taskBar->bTimer)
4236+
{
4237+
taskBar->bTimer=false;
4238+
if (taskBar->startButton)
4239+
KillTimer(taskBar->startButton,'CLSM');
4240+
if (taskBar->oldButton && taskBar->oldButton!=taskBar->startButton)
4241+
KillTimer(taskBar->oldButton,'CLSM');
4242+
}
42324243
ShowWinX();
42334244
}
42344245
else if (bShowWin7)

0 commit comments

Comments
 (0)