aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2022-08-03 11:38:57 -0500
committerSean Hall <r.sean.hall@gmail.com>2022-08-03 12:40:37 -0500
commit7e2a9522351c58c45c7185f9e97b3b2faf1f9c90 (patch)
treeeb9a3448633916cd0e4ba9309ddc66a9ba886abb
parentfa54ae44e565d4e8d273627f2fc73e670febeea2 (diff)
downloadwix-7e2a9522351c58c45c7185f9e97b3b2faf1f9c90.tar.gz
wix-7e2a9522351c58c45c7185f9e97b3b2faf1f9c90.tar.bz2
wix-7e2a9522351c58c45c7185f9e97b3b2faf1f9c90.zip
Make the clean room process replace the splash screen with its own.
This is required to get Windows to automatically transfer foreground focus so that the BA's window or the elevation prompt is automatically activated. Fixes 6836
-rw-r--r--src/burn/engine/engine.cpp2
-rw-r--r--src/burn/engine/splashscreen.cpp19
-rw-r--r--src/test/burn/WixToolsetTest.BurnE2E/WixIuiBaTests.cs2
3 files changed, 21 insertions, 2 deletions
diff --git a/src/burn/engine/engine.cpp b/src/burn/engine/engine.cpp
index 413db69b..334ea23b 100644
--- a/src/burn/engine/engine.cpp
+++ b/src/burn/engine/engine.cpp
@@ -132,7 +132,7 @@ extern "C" HRESULT EngineRun(
132 132
133 engineState.command.nCmdShow = nCmdShow; 133 engineState.command.nCmdShow = nCmdShow;
134 134
135 if (BURN_MODE_ELEVATED != engineState.internalCommand.mode && BOOTSTRAPPER_DISPLAY_NONE < engineState.command.display && !engineState.command.hwndSplashScreen) 135 if (BURN_MODE_ELEVATED != engineState.internalCommand.mode && BOOTSTRAPPER_DISPLAY_NONE < engineState.command.display)
136 { 136 {
137 SplashScreenCreate(hInstance, NULL, &engineState.command.hwndSplashScreen); 137 SplashScreenCreate(hInstance, NULL, &engineState.command.hwndSplashScreen);
138 } 138 }
diff --git a/src/burn/engine/splashscreen.cpp b/src/burn/engine/splashscreen.cpp
index 7ba4e630..d8618feb 100644
--- a/src/burn/engine/splashscreen.cpp
+++ b/src/burn/engine/splashscreen.cpp
@@ -13,6 +13,7 @@ struct SPLASHSCREEN_INFO
13 SIZE size; 13 SIZE size;
14 UINT nDpi; 14 UINT nDpi;
15 HWND hWnd; 15 HWND hWnd;
16 HWND hwndPrevious;
16}; 17};
17 18
18struct SPLASHSCREEN_CONTEXT 19struct SPLASHSCREEN_CONTEXT
@@ -258,6 +259,19 @@ static LRESULT CALLBACK WndProc(
258 case WM_ERASEBKGND: 259 case WM_ERASEBKGND:
259 OnEraseBkgnd(pSplashScreen, wParam); 260 OnEraseBkgnd(pSplashScreen, wParam);
260 return 1; 261 return 1;
262
263 case WM_ENTERIDLE:
264 lres = ::DefWindowProcW(hWnd, uMsg, wParam, lParam);
265
266 // We had to create our own splash screen so that Windows would automatically transfer focus from the other process's splash screen.
267 // Try to make sure new splash screen has painted before closing old one to avoid flickering.
268 if (pSplashScreen->hwndPrevious)
269 {
270 ::PostMessageW(pSplashScreen->hwndPrevious, WM_CLOSE, 0, 0);
271 pSplashScreen->hwndPrevious = NULL;
272 }
273
274 return lres;
261 } 275 }
262 276
263 return ::DefWindowProcW(hWnd, uMsg, wParam, lParam); 277 return ::DefWindowProcW(hWnd, uMsg, wParam, lParam);
@@ -276,6 +290,11 @@ static HRESULT LoadSplashScreen(
276 DPIU_MONITOR_CONTEXT* pMonitorContext = NULL; 290 DPIU_MONITOR_CONTEXT* pMonitorContext = NULL;
277 RECT* pMonitorRect = NULL; 291 RECT* pMonitorRect = NULL;
278 292
293 if (::IsWindow(*pContext->pHwnd))
294 {
295 pSplashScreen->hwndPrevious = *pContext->pHwnd;
296 }
297
279 pSplashScreen->nDpi = USER_DEFAULT_SCREEN_DPI; 298 pSplashScreen->nDpi = USER_DEFAULT_SCREEN_DPI;
280 pSplashScreen->hBitmap = ::LoadBitmapW(pContext->hInstance, MAKEINTRESOURCEW(pContext->pSplashScreenConfiguration->wResourceId)); 299 pSplashScreen->hBitmap = ::LoadBitmapW(pContext->hInstance, MAKEINTRESOURCEW(pContext->pSplashScreenConfiguration->wResourceId));
281 ExitOnNullWithLastError(pSplashScreen->hBitmap, hr, "Failed to load splash screen bitmap."); 300 ExitOnNullWithLastError(pSplashScreen->hBitmap, hr, "Failed to load splash screen bitmap.");
diff --git a/src/test/burn/WixToolsetTest.BurnE2E/WixIuiBaTests.cs b/src/test/burn/WixToolsetTest.BurnE2E/WixIuiBaTests.cs
index 18dd41db..3e7e3ded 100644
--- a/src/test/burn/WixToolsetTest.BurnE2E/WixIuiBaTests.cs
+++ b/src/test/burn/WixToolsetTest.BurnE2E/WixIuiBaTests.cs
@@ -114,7 +114,7 @@ namespace WixToolsetTest.BurnE2E
114 // Manual test for InternalUIBundle: 114 // Manual test for InternalUIBundle:
115 // 1. Double click InternalUIBundle.exe on a machine that will prompt for elevation. 115 // 1. Double click InternalUIBundle.exe on a machine that will prompt for elevation.
116 // 2. Verify that the splash screen appeared but the prereq BA did not come up. 116 // 2. Verify that the splash screen appeared but the prereq BA did not come up.
117 // 3. Verify that the elevation prompt came up immediately instead of flashing on the taskbar. (This is currently broken) 117 // 3. Verify that the elevation prompt came up immediately instead of flashing on the taskbar.
118 // 4. Allow elevation. 118 // 4. Allow elevation.
119 // 5. Verify that the MSI UI came up and the splash screen disappeared. 119 // 5. Verify that the MSI UI came up and the splash screen disappeared.
120 // 6. Accept the two CA messages and click the install button. 120 // 6. Accept the two CA messages and click the install button.