use tauri::{Runtime, WebviewWindow};
use windows_sys::Win32::{
Foundation::HWND,
Graphics::Dwm::{DWMWA_WINDOW_CORNER_PREFERENCE, DWMWCP_DONOTROUND, DwmSetWindowAttribute},
UI::WindowsAndMessaging::{
GWL_EXSTYLE,
GetWindowLongPtrW,
HWND_TOPMOST,
SWP_NOACTIVATE,
SWP_NOMOVE,
SWP_NOSIZE,
SetWindowLongPtrW,
SetWindowPos,
WS_EX_NOACTIVATE,
WS_EX_TOOLWINDOW,
WS_EX_TRANSPARENT,
},
};
pub fn raise<R:Runtime>(window:&WebviewWindow<R>) {
let Ok(handle) = window.hwnd() else {
return;
};
let hwnd = handle.0 as HWND;
let _ = (!hwnd.is_null()).then(|| unsafe {
let style = GetWindowLongPtrW(hwnd, GWL_EXSTYLE);
let extra = (WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE | WS_EX_TRANSPARENT) as isize;
SetWindowLongPtrW(hwnd, GWL_EXSTYLE, style | extra);
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
let corner:i32 = DWMWCP_DONOTROUND;
DwmSetWindowAttribute(
hwnd,
DWMWA_WINDOW_CORNER_PREFERENCE as u32,
&corner as *const i32 as *const core::ffi::c_void,
std::mem::size_of::<i32>() as u32,
);
});
}
pub fn dock(_visible:bool) {}