diff --git a/packages/wm/src/common/platform/platform.rs b/packages/wm/src/common/platform/platform.rs index 5a3afc9e9..62a151828 100644 --- a/packages/wm/src/common/platform/platform.rs +++ b/packages/wm/src/common/platform/platform.rs @@ -21,7 +21,7 @@ use windows::{ CreateWindowExW, DispatchMessageW, GetAncestor, GetCursorPos, GetDesktopWindow, GetForegroundWindow, GetMessageW, MessageBoxW, PeekMessageW, PostThreadMessageW, RegisterClassW, SetCursorPos, - SystemParametersInfoW, TranslateMessage, WindowFromPoint, + SystemParametersInfoW, TranslateMessage, WindowFromPoint, GetShellWindow, ANIMATIONINFO, CS_HREDRAW, CS_VREDRAW, CW_USEDEFAULT, GA_ROOT, MB_ICONERROR, MB_OK, MB_SYSTEMMODAL, MSG, PM_REMOVE, SPI_GETANIMATION, SPI_SETANIMATION, SW_NORMAL, SW_HIDE, @@ -49,9 +49,14 @@ impl Platform { NativeWindow::new(handle.0) } - /// Gets the `NativeWindow` instance of the desktop window. + // Get Explorer wallpaper window (i.e. "Progman"). Default to the + // desktop window on which the wallpaper window sits above for edge + // case where Explorer isn't running. pub fn desktop_window() -> NativeWindow { - let handle = unsafe { GetDesktopWindow() }; + let mut handle = unsafe { GetShellWindow() }; + if handle == HWND(0) { + handle = unsafe { GetDesktopWindow() }; + } NativeWindow::new(handle.0) }