//! The window frame: the title bar style of each platform, and Snap Layouts on Windows 11. use crate::error::Result; /// Give a window that RuneStone builds at run time the title bar of its platform. /// Windows and Linux windows draw their own title bar. macOS keeps its native traffic lights over the web content. pub fn title_bar<'a, R: tauri::Runtime, M: tauri::Manager>(builder: tauri::WebviewWindowBuilder<'a, R, M>) -> tauri::WebviewWindowBuilder<'a, R, M> { #[cfg(target_os = "macos")] { builder.title_bar_style(tauri::TitleBarStyle::Overlay).hidden_title(true) } #[cfg(not(target_os = "macos"))] { builder.decorations(false) } } /// Open the Snap Layouts flyout of the focused window, as a native maximize button does on hover. /// The custom title bar has no native caption buttons, so the host presses Win+Z. A window without focus does nothing. #[tauri::command] pub fn window_snap_layouts(window: tauri::Window) -> Result<()> { #[cfg(windows)] { use windows_sys::Win32::UI::Input::KeyboardAndMouse::{keybd_event, KEYEVENTF_KEYUP, VK_LWIN}; if !window.is_focused().map_err(crate::error::Error::from_display)? { return Ok(()); } unsafe { keybd_event(VK_LWIN as u8, 0, 0, 0); keybd_event(b'Z', 0, 0, 0); keybd_event(b'Z', 0, KEYEVENTF_KEYUP, 0); keybd_event(VK_LWIN as u8, 0, KEYEVENTF_KEYUP, 0); } } #[cfg(not(windows))] { let _ = window; } Ok(()) }