Skip to content

Commit

Permalink
use GetShellWindow() as default workspace window
Browse files Browse the repository at this point in the history
  • Loading branch information
DreamMaoMao committed Nov 5, 2024
1 parent 54cbe06 commit 9b34f90
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/wm/src/common/platform/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ use windows::{
},
WindowsAndMessaging::{
CreateWindowExW, DispatchMessageW, GetAncestor, GetCursorPos,
FindWindowA, GetForegroundWindow, GetMessageW, MessageBoxW,
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,
Expand Down Expand Up @@ -49,11 +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 {
FindWindowA(PCSTR("Progman\0".as_ptr() as *const u8), PCSTR::null())
};
let mut handle = unsafe { GetShellWindow() };
if handle == HWND(0) {
handle = unsafe { GetDesktopWindow() };
}
NativeWindow::new(handle.0)
}

Expand Down

0 comments on commit 9b34f90

Please sign in to comment.