Visual Studio Code, rebuilt in Rust
Rust
fix(windows): read always on top as off on GPUI's test windows
rokartur4b65f2f5bc62
diff --git a/native/crates/app/src/win32.rs b/native/crates/app/src/win32.rsindex bd9afc306b8..78fffc9d345 100644--- a/native/crates/app/src/win32.rs+++ b/native/crates/app/src/win32.rs@@ -7,22 +7,23 @@ use windows_sys::Win32::UI::WindowsAndMessaging::{GWL_EXSTYLE, GetWindowLongPtrW, HWND_NOTOPMOST, HWND_TOPMOST, SWP_NOACTIVATE, SWP_NOMOVE, SWP_NOSIZE, SetWindowPos, WS_EX_TOPMOST,};-/// The HWND of a GPUI window, which GPUI's Windows platform always has.-pub fn hwnd(window: &Window) -> HWND {- match HasWindowHandle::window_handle(window).expect("a GPUI window has a handle").as_raw() {- RawWindowHandle::Win32(handle) => handle.hwnd.get() as HWND,- handle => unreachable!("GPUI's Windows platform gave {handle:?}"),+/// The HWND of a GPUI window; none on GPUI's test platform.+fn hwnd(window: &Window) -> Option<HWND> {+ match HasWindowHandle::window_handle(window).ok()?.as_raw() {+ RawWindowHandle::Win32(handle) => Some(handle.hwnd.get() as HWND),+ _ => None,}}/// Chromium's HWNDMessageHandler `SetAlwaysOnTop` reads it back from the extended style.pub fn is_always_on_top(window: &Window) -> bool {// SAFETY: a live window's HWND.- unsafe { GetWindowLongPtrW(hwnd(window), GWL_EXSTYLE) as u32 & WS_EX_TOPMOST != 0 }+ hwnd(window).is_some_and(|hwnd| unsafe { GetWindowLongPtrW(hwnd, GWL_EXSTYLE) } as u32 & WS_EX_TOPMOST != 0)}pub fn set_always_on_top(window: &Window, on_top: bool) {+ let hwnd = hwnd(window).expect("Windows windows are Win32 windows");let after = if on_top { HWND_TOPMOST } else { HWND_NOTOPMOST };// SAFETY: a live window's HWND; only the z-order changes.- unsafe { SetWindowPos(hwnd(window), after, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE) };+ unsafe { SetWindowPos(hwnd, after, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE) };}