1use winit::window::Window;
2
3#[cfg(windows)]
4pub fn round_window_corners(window: &Window) {
5 use winit::raw_window_handle::{HasWindowHandle, RawWindowHandle};
6 use windows_sys::Win32::Graphics::Dwm::{
7 DwmSetWindowAttribute, DWMWA_WINDOW_CORNER_PREFERENCE, DWMWCP_ROUND,
8 };
9
10 let Ok(handle) = window.window_handle() else { return };
11 let RawWindowHandle::Win32(win32_handle) = handle.as_raw() else { return };
12 let hwnd = win32_handle.hwnd.get() as windows_sys::Win32::Foundation::HWND;
13 let preference = DWMWCP_ROUND;
14
15 unsafe {
16 DwmSetWindowAttribute(
17 hwnd,
18 DWMWA_WINDOW_CORNER_PREFERENCE as u32,
19 &preference as *const _ as *const std::ffi::c_void,
20 std::mem::size_of_val(&preference) as u32,
21 );
22 }
23}
24
25#[cfg(not(windows))]
26pub fn round_window_corners(_window: &Window) {}