pub(crate) mod plugin;
use tauri_runtime::{
dpi::{PhysicalPosition, PhysicalSize},
webview::PendingWebview,
};
pub use tauri_utils::{config::Color, WindowEffect as Effect, WindowEffectState as EffectState};
#[cfg(desktop)]
pub use crate::runtime::ProgressBarStatus;
use crate::{
app::AppHandle,
event::{Event, EventId, EventTarget},
ipc::{CommandArg, CommandItem, InvokeError},
manager::AppManager,
runtime::{
monitor::Monitor as RuntimeMonitor,
window::{DetachedWindow, PendingWindow, WindowBuilder as _},
RuntimeHandle, WindowDispatch,
},
sealed::{ManagerBase, RuntimeOrDispatch},
utils::config::{WindowConfig, WindowEffectsConfig},
webview::WebviewBuilder,
Emitter, EventLoopMessage, Listener, Manager, ResourceTable, Runtime, Theme, Webview,
WindowEvent,
};
#[cfg(desktop)]
use crate::{
image::Image,
menu::{ContextMenu, Menu, MenuId},
runtime::{
dpi::{Position, Size},
UserAttentionType,
},
CursorIcon,
};
use serde::Serialize;
#[cfg(windows)]
use windows::Win32::Foundation::HWND;
use tauri_macros::default_runtime;
use std::{
fmt,
hash::{Hash, Hasher},
sync::{Arc, Mutex, MutexGuard},
};
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Monitor {
pub(crate) name: Option<String>,
pub(crate) size: PhysicalSize<u32>,
pub(crate) position: PhysicalPosition<i32>,
pub(crate) scale_factor: f64,
}
impl From<RuntimeMonitor> for Monitor {
fn from(monitor: RuntimeMonitor) -> Self {
Self {
name: monitor.name,
size: monitor.size,
position: monitor.position,
scale_factor: monitor.scale_factor,
}
}
}
impl Monitor {
pub fn name(&self) -> Option<&String> {
self.name.as_ref()
}
pub fn size(&self) -> &PhysicalSize<u32> {
&self.size
}
pub fn position(&self) -> &PhysicalPosition<i32> {
&self.position
}
pub fn scale_factor(&self) -> f64 {
self.scale_factor
}
}
macro_rules! unstable_struct {
(#[doc = $doc:expr] $($tokens:tt)*) => {
#[cfg(feature = "unstable")]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
#[doc = $doc]
pub $($tokens)*
#[cfg(not(feature = "unstable"))]
pub(crate) $($tokens)*
}
}
unstable_struct!(
#[doc = "A builder for a window managed by Tauri."]
struct WindowBuilder<'a, R: Runtime, M: Manager<R>> {
manager: &'a M,
pub(crate) label: String,
pub(crate) window_builder:
<R::WindowDispatcher as WindowDispatch<EventLoopMessage>>::WindowBuilder,
#[cfg(desktop)]
pub(crate) menu: Option<Menu<R>>,
#[cfg(desktop)]
on_menu_event: Option<crate::app::GlobalMenuEventListener<Window<R>>>,
window_effects: Option<WindowEffectsConfig>,
}
);
impl<R: Runtime, M: Manager<R>> fmt::Debug for WindowBuilder<'_, R, M> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("WindowBuilder")
.field("label", &self.label)
.field("window_builder", &self.window_builder)
.finish()
}
}
#[cfg_attr(not(feature = "unstable"), allow(dead_code))]
impl<'a, R: Runtime, M: Manager<R>> WindowBuilder<'a, R, M> {
#[cfg_attr(
feature = "unstable",
doc = r####"
```
tauri::Builder::default()
.setup(|app| {
let window = tauri::window::WindowBuilder::new(app, "label")
.build()?;
Ok(())
});
```
"####
)]
#[cfg_attr(
feature = "unstable",
doc = r####"
```
tauri::Builder::default()
.setup(|app| {
let handle = app.handle().clone();
std::thread::spawn(move || {
let window = tauri::window::WindowBuilder::new(&handle, "label")
.build()
.unwrap();
});
Ok(())
});
```
"####
)]
#[cfg_attr(
feature = "unstable",
doc = r####"
```
#[tauri::command]
async fn create_window(app: tauri::AppHandle) {
let window = tauri::window::WindowBuilder::new(&app, "label")
.build()
.unwrap();
}
```
"####
)]
pub fn new<L: Into<String>>(manager: &'a M, label: L) -> Self {
Self {
manager,
label: label.into(),
window_builder: <R::WindowDispatcher as WindowDispatch<EventLoopMessage>>::WindowBuilder::new(
),
#[cfg(desktop)]
menu: None,
#[cfg(desktop)]
on_menu_event: None,
window_effects: None,
}
}
#[cfg_attr(
feature = "unstable",
doc = r####"
```
#[tauri::command]
async fn reopen_window(app: tauri::AppHandle) {
let window = tauri::window::WindowBuilder::from_config(&app, &app.config().app.windows.get(0).unwrap().clone())
.unwrap()
.build()
.unwrap();
}
```
"####
)]
pub fn from_config(manager: &'a M, config: &WindowConfig) -> crate::Result<Self> {
#[cfg_attr(not(windows), allow(unused_mut))]
let mut builder = Self {
manager,
label: config.label.clone(),
window_effects: config.window_effects.clone(),
window_builder:
<R::WindowDispatcher as WindowDispatch<EventLoopMessage>>::WindowBuilder::with_config(
config,
),
#[cfg(desktop)]
menu: None,
#[cfg(desktop)]
on_menu_event: None,
};
#[cfg(desktop)]
if let Some(parent) = &config.parent {
let window = manager
.manager()
.get_window(parent)
.ok_or(crate::Error::WindowNotFound)?;
builder = builder.parent(&window)?;
}
Ok(builder)
}
#[cfg_attr(
feature = "unstable",
doc = r####"
```
use tauri::menu::{Menu, Submenu, MenuItem};
tauri::Builder::default()
.setup(|app| {
let handle = app.handle();
let save_menu_item = MenuItem::new(handle, "Save", true, None::<&str>)?;
let menu = Menu::with_items(handle, &[
&Submenu::with_items(handle, "File", true, &[
&save_menu_item,
])?,
])?;
let window = tauri::window::WindowBuilder::new(app, "editor")
.menu(menu)
.on_menu_event(move |window, event| {
if event.id == save_menu_item.id() {
// save menu item
}
})
.build()
.unwrap();
///
Ok(())
});
```"####
)]
#[cfg(desktop)]
pub fn on_menu_event<F: Fn(&Window<R>, crate::menu::MenuEvent) + Send + Sync + 'static>(
mut self,
f: F,
) -> Self {
self.on_menu_event.replace(Box::new(f));
self
}
#[cfg_attr(
feature = "tracing",
tracing::instrument(name = "webview::create", skip_all)
)]
pub(crate) fn with_webview(
self,
webview: WebviewBuilder<R>,
) -> crate::Result<(Window<R>, Webview<R>)> {
let pending_webview = webview.into_pending_webview(self.manager, &self.label)?;
let window = self.build_internal(Some(pending_webview))?;
let webview = window.webviews().first().unwrap().clone();
Ok((window, webview))
}
pub fn build(self) -> crate::Result<Window<R>> {
self.build_internal(None)
}
fn build_internal(
self,
webview: Option<PendingWebview<EventLoopMessage, R>>,
) -> crate::Result<Window<R>> {
let mut pending = PendingWindow::new(self.window_builder.clone(), self.label.clone())?;
if let Some(webview) = webview {
pending.set_webview(webview);
}
let app_manager = self.manager.manager();
let pending = app_manager.window.prepare_window(pending)?;
#[cfg(desktop)]
let window_menu = {
let is_app_wide = self.menu.is_none();
self
.menu
.or_else(|| self.manager.app_handle().menu())
.map(|menu| WindowMenu { is_app_wide, menu })
};
#[cfg(desktop)]
let handler = app_manager
.menu
.prepare_window_menu_creation_handler(window_menu.as_ref(), self.window_builder.get_theme());
#[cfg(not(desktop))]
#[allow(clippy::type_complexity)]
let handler: Option<Box<dyn Fn(tauri_runtime::window::RawWindow<'_>) + Send>> = None;
let window = match &mut self.manager.runtime() {
RuntimeOrDispatch::Runtime(runtime) => runtime.create_window(pending, handler),
RuntimeOrDispatch::RuntimeHandle(handle) => handle.create_window(pending, handler),
RuntimeOrDispatch::Dispatch(dispatcher) => dispatcher.create_window(pending, handler),
}
.map(|detached_window| {
let window = app_manager.window.attach_window(
self.manager.app_handle().clone(),
detached_window.clone(),
#[cfg(desktop)]
window_menu,
);
if let Some(webview) = detached_window.webview {
app_manager.webview.attach_webview(
window.clone(),
webview.webview,
webview.use_https_scheme,
);
}
window
})?;
#[cfg(desktop)]
if let Some(handler) = self.on_menu_event {
window.on_menu_event(handler);
}
if let Some(effects) = self.window_effects {
crate::vibrancy::set_window_effects(&window, Some(effects))?;
}
let app_manager = self.manager.manager_owned();
let window_label = window.label().to_string();
let _ = window.run_on_main_thread(move || {
let _ = app_manager.emit(
"tauri://window-created",
Some(crate::webview::CreatedEvent {
label: window_label,
}),
);
});
Ok(window)
}
}
#[cfg(desktop)]
#[cfg_attr(not(feature = "unstable"), allow(dead_code))]
impl<'a, R: Runtime, M: Manager<R>> WindowBuilder<'a, R, M> {
#[must_use]
pub fn menu(mut self, menu: Menu<R>) -> Self {
self.menu.replace(menu);
self
}
#[must_use]
pub fn center(mut self) -> Self {
self.window_builder = self.window_builder.center();
self
}
#[must_use]
pub fn position(mut self, x: f64, y: f64) -> Self {
self.window_builder = self.window_builder.position(x, y);
self
}
#[must_use]
pub fn inner_size(mut self, width: f64, height: f64) -> Self {
self.window_builder = self.window_builder.inner_size(width, height);
self
}
#[must_use]
pub fn min_inner_size(mut self, min_width: f64, min_height: f64) -> Self {
self.window_builder = self.window_builder.min_inner_size(min_width, min_height);
self
}
#[must_use]
pub fn max_inner_size(mut self, max_width: f64, max_height: f64) -> Self {
self.window_builder = self.window_builder.max_inner_size(max_width, max_height);
self
}
#[must_use]
pub fn inner_size_constraints(
mut self,
constraints: tauri_runtime::window::WindowSizeConstraints,
) -> Self {
self.window_builder = self.window_builder.inner_size_constraints(constraints);
self
}
#[must_use]
pub fn resizable(mut self, resizable: bool) -> Self {
self.window_builder = self.window_builder.resizable(resizable);
self
}
#[must_use]
pub fn maximizable(mut self, maximizable: bool) -> Self {
self.window_builder = self.window_builder.maximizable(maximizable);
self
}
#[must_use]
pub fn minimizable(mut self, minimizable: bool) -> Self {
self.window_builder = self.window_builder.minimizable(minimizable);
self
}
#[must_use]
pub fn closable(mut self, closable: bool) -> Self {
self.window_builder = self.window_builder.closable(closable);
self
}
#[must_use]
pub fn title<S: Into<String>>(mut self, title: S) -> Self {
self.window_builder = self.window_builder.title(title);
self
}
#[must_use]
pub fn fullscreen(mut self, fullscreen: bool) -> Self {
self.window_builder = self.window_builder.fullscreen(fullscreen);
self
}
#[must_use]
#[deprecated(
since = "1.2.0",
note = "The window is automatically focused by default. This function Will be removed in 3.0.0. Use `focused` instead."
)]
pub fn focus(mut self) -> Self {
self.window_builder = self.window_builder.focused(true);
self
}
#[must_use]
pub fn focused(mut self, focused: bool) -> Self {
self.window_builder = self.window_builder.focused(focused);
self
}
#[must_use]
pub fn maximized(mut self, maximized: bool) -> Self {
self.window_builder = self.window_builder.maximized(maximized);
self
}
#[must_use]
pub fn visible(mut self, visible: bool) -> Self {
self.window_builder = self.window_builder.visible(visible);
self
}
#[must_use]
pub fn theme(mut self, theme: Option<Theme>) -> Self {
self.window_builder = self.window_builder.theme(theme);
self
}
#[cfg(any(not(target_os = "macos"), feature = "macos-private-api"))]
#[cfg_attr(
docsrs,
doc(cfg(any(not(target_os = "macos"), feature = "macos-private-api")))
)]
#[must_use]
pub fn transparent(mut self, transparent: bool) -> Self {
self.window_builder = self.window_builder.transparent(transparent);
self
}
#[must_use]
pub fn decorations(mut self, decorations: bool) -> Self {
self.window_builder = self.window_builder.decorations(decorations);
self
}
#[must_use]
pub fn always_on_bottom(mut self, always_on_bottom: bool) -> Self {
self.window_builder = self.window_builder.always_on_bottom(always_on_bottom);
self
}
#[must_use]
pub fn always_on_top(mut self, always_on_top: bool) -> Self {
self.window_builder = self.window_builder.always_on_top(always_on_top);
self
}
#[must_use]
pub fn visible_on_all_workspaces(mut self, visible_on_all_workspaces: bool) -> Self {
self.window_builder = self
.window_builder
.visible_on_all_workspaces(visible_on_all_workspaces);
self
}
#[must_use]
pub fn content_protected(mut self, protected: bool) -> Self {
self.window_builder = self.window_builder.content_protected(protected);
self
}
pub fn icon(mut self, icon: Image<'a>) -> crate::Result<Self> {
self.window_builder = self.window_builder.icon(icon.into())?;
Ok(self)
}
#[must_use]
pub fn skip_taskbar(mut self, skip: bool) -> Self {
self.window_builder = self.window_builder.skip_taskbar(skip);
self
}
#[must_use]
pub fn window_classname<S: Into<String>>(mut self, classname: S) -> Self {
self.window_builder = self.window_builder.window_classname(classname);
self
}
#[must_use]
pub fn shadow(mut self, enable: bool) -> Self {
self.window_builder = self.window_builder.shadow(enable);
self
}
pub fn parent(mut self, parent: &Window<R>) -> crate::Result<Self> {
#[cfg(windows)]
{
self.window_builder = self.window_builder.owner(parent.hwnd()?);
}
#[cfg(any(
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd"
))]
{
self.window_builder = self.window_builder.transient_for(&parent.gtk_window()?);
}
#[cfg(target_os = "macos")]
{
self.window_builder = self.window_builder.parent(parent.ns_window()?);
}
Ok(self)
}
#[cfg(windows)]
pub fn owner(mut self, owner: &Window<R>) -> crate::Result<Self> {
self.window_builder = self.window_builder.owner(owner.hwnd()?);
Ok(self)
}
#[cfg(windows)]
#[must_use]
pub fn owner_raw(mut self, owner: HWND) -> Self {
self.window_builder = self.window_builder.owner(owner);
self
}
#[cfg(windows)]
#[must_use]
pub fn parent_raw(mut self, parent: HWND) -> Self {
self.window_builder = self.window_builder.parent(parent);
self
}
#[cfg(target_os = "macos")]
#[must_use]
pub fn parent_raw(mut self, parent: *mut std::ffi::c_void) -> Self {
self.window_builder = self.window_builder.parent(parent);
self
}
#[cfg(any(
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd"
))]
pub fn transient_for(mut self, parent: &Window<R>) -> crate::Result<Self> {
self.window_builder = self.window_builder.transient_for(&parent.gtk_window()?);
Ok(self)
}
#[cfg(any(
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd"
))]
#[must_use]
pub fn transient_for_raw(mut self, parent: &impl gtk::glib::IsA<gtk::Window>) -> Self {
self.window_builder = self.window_builder.transient_for(parent);
self
}
#[cfg(windows)]
#[must_use]
pub fn drag_and_drop(mut self, enabled: bool) -> Self {
self.window_builder = self.window_builder.drag_and_drop(enabled);
self
}
#[cfg(target_os = "macos")]
#[must_use]
pub fn title_bar_style(mut self, style: crate::TitleBarStyle) -> Self {
self.window_builder = self.window_builder.title_bar_style(style);
self
}
#[cfg(target_os = "macos")]
#[must_use]
pub fn hidden_title(mut self, hidden: bool) -> Self {
self.window_builder = self.window_builder.hidden_title(hidden);
self
}
#[cfg(target_os = "macos")]
#[must_use]
pub fn tabbing_identifier(mut self, identifier: &str) -> Self {
self.window_builder = self.window_builder.tabbing_identifier(identifier);
self
}
pub fn effects(mut self, effects: WindowEffectsConfig) -> Self {
self.window_effects.replace(effects);
self
}
}
impl<R: Runtime, M: Manager<R>> WindowBuilder<'_, R, M> {
#[must_use]
pub fn background_color(mut self, color: Color) -> Self {
self.window_builder = self.window_builder.background_color(color);
self
}
}
#[cfg(desktop)]
pub(crate) struct WindowMenu<R: Runtime> {
pub(crate) is_app_wide: bool,
pub(crate) menu: Menu<R>,
}
#[default_runtime(crate::Wry, wry)]
pub struct Window<R: Runtime> {
pub(crate) window: DetachedWindow<EventLoopMessage, R>,
pub(crate) manager: Arc<AppManager<R>>,
pub(crate) app_handle: AppHandle<R>,
#[cfg(desktop)]
pub(crate) menu: Arc<Mutex<Option<WindowMenu<R>>>>,
pub(crate) resources_table: Arc<Mutex<ResourceTable>>,
}
impl<R: Runtime> std::fmt::Debug for Window<R> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Window")
.field("window", &self.window)
.field("manager", &self.manager)
.field("app_handle", &self.app_handle)
.finish()
}
}
impl<R: Runtime> raw_window_handle::HasWindowHandle for Window<R> {
fn window_handle(
&self,
) -> std::result::Result<raw_window_handle::WindowHandle<'_>, raw_window_handle::HandleError> {
self.window.dispatcher.window_handle()
}
}
impl<R: Runtime> raw_window_handle::HasDisplayHandle for Window<R> {
fn display_handle(
&self,
) -> std::result::Result<raw_window_handle::DisplayHandle<'_>, raw_window_handle::HandleError> {
self.app_handle.display_handle()
}
}
impl<R: Runtime> Clone for Window<R> {
fn clone(&self) -> Self {
Self {
window: self.window.clone(),
manager: self.manager.clone(),
app_handle: self.app_handle.clone(),
#[cfg(desktop)]
menu: self.menu.clone(),
resources_table: self.resources_table.clone(),
}
}
}
impl<R: Runtime> Hash for Window<R> {
fn hash<H: Hasher>(&self, state: &mut H) {
self.window.label.hash(state)
}
}
impl<R: Runtime> Eq for Window<R> {}
impl<R: Runtime> PartialEq for Window<R> {
fn eq(&self, other: &Self) -> bool {
self.window.label.eq(&other.window.label)
}
}
impl<R: Runtime> Manager<R> for Window<R> {
fn resources_table(&self) -> MutexGuard<'_, ResourceTable> {
self
.resources_table
.lock()
.expect("poisoned window resources table")
}
}
impl<R: Runtime> ManagerBase<R> for Window<R> {
fn manager(&self) -> &AppManager<R> {
&self.manager
}
fn manager_owned(&self) -> Arc<AppManager<R>> {
self.manager.clone()
}
fn runtime(&self) -> RuntimeOrDispatch<'_, R> {
RuntimeOrDispatch::Dispatch(self.window.dispatcher.clone())
}
fn managed_app_handle(&self) -> &AppHandle<R> {
&self.app_handle
}
}
impl<'de, R: Runtime> CommandArg<'de, R> for Window<R> {
fn from_command(command: CommandItem<'de, R>) -> Result<Self, InvokeError> {
Ok(command.message.webview().window())
}
}
impl<R: Runtime> Window<R> {
pub(crate) fn new(
manager: Arc<AppManager<R>>,
window: DetachedWindow<EventLoopMessage, R>,
app_handle: AppHandle<R>,
#[cfg(desktop)] menu: Option<WindowMenu<R>>,
) -> Self {
Self {
window,
manager,
app_handle,
#[cfg(desktop)]
menu: Arc::new(std::sync::Mutex::new(menu)),
resources_table: Default::default(),
}
}
#[cfg(feature = "unstable")]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
pub fn builder<M: Manager<R>, L: Into<String>>(manager: &M, label: L) -> WindowBuilder<'_, R, M> {
WindowBuilder::new(manager, label.into())
}
#[cfg(any(test, all(desktop, feature = "unstable")))]
#[cfg_attr(docsrs, doc(cfg(all(desktop, feature = "unstable"))))]
pub fn add_child<P: Into<Position>, S: Into<Size>>(
&self,
webview_builder: WebviewBuilder<R>,
position: P,
size: S,
) -> crate::Result<Webview<R>> {
use std::sync::mpsc::channel;
let (tx, rx) = channel();
let position = position.into();
let size = size.into();
let window_ = self.clone();
self.run_on_main_thread(move || {
let res = webview_builder.build(window_, position, size);
tx.send(res.map_err(Into::into)).unwrap();
})?;
rx.recv().unwrap()
}
pub fn webviews(&self) -> Vec<Webview<R>> {
self
.manager
.webview
.webviews_lock()
.values()
.filter(|w| w.window_label() == self.label())
.cloned()
.collect()
}
pub(crate) fn is_webview_window(&self) -> bool {
self.webviews().iter().all(|w| w.label() == self.label())
}
pub fn run_on_main_thread<F: FnOnce() + Send + 'static>(&self, f: F) -> crate::Result<()> {
self
.window
.dispatcher
.run_on_main_thread(f)
.map_err(Into::into)
}
pub fn label(&self) -> &str {
&self.window.label
}
pub fn on_window_event<F: Fn(&WindowEvent) + Send + 'static>(&self, f: F) {
self
.window
.dispatcher
.on_window_event(move |event| f(&event.clone().into()));
}
}
#[cfg(desktop)]
impl<R: Runtime> Window<R> {
#[cfg_attr(
feature = "unstable",
doc = r####"
```
use tauri::menu::{Menu, Submenu, MenuItem};
tauri::Builder::default()
.setup(|app| {
let handle = app.handle();
let save_menu_item = MenuItem::new(handle, "Save", true, None::<&str>)?;
let menu = Menu::with_items(handle, &[
&Submenu::with_items(handle, "File", true, &[
&save_menu_item,
])?,
])?;
let window = tauri::window::WindowBuilder::new(app, "editor")
.menu(menu)
.build()
.unwrap();
window.on_menu_event(move |window, event| {
if event.id == save_menu_item.id() {
// save menu item
}
});
Ok(())
});
```
"####
)]
pub fn on_menu_event<F: Fn(&Window<R>, crate::menu::MenuEvent) + Send + Sync + 'static>(
&self,
f: F,
) {
self
.manager
.menu
.event_listeners
.lock()
.unwrap()
.insert(self.label().to_string(), Box::new(f));
}
pub(crate) fn menu_lock(&self) -> std::sync::MutexGuard<'_, Option<WindowMenu<R>>> {
self.menu.lock().expect("poisoned window")
}
#[cfg_attr(target_os = "macos", allow(dead_code))]
pub(crate) fn has_app_wide_menu(&self) -> bool {
self
.menu_lock()
.as_ref()
.map(|m| m.is_app_wide)
.unwrap_or(false)
}
#[cfg_attr(target_os = "macos", allow(dead_code))]
pub(crate) fn is_menu_in_use<I: PartialEq<MenuId>>(&self, id: &I) -> bool {
self
.menu_lock()
.as_ref()
.map(|m| id.eq(m.menu.id()))
.unwrap_or(false)
}
pub fn menu(&self) -> Option<Menu<R>> {
self.menu_lock().as_ref().map(|m| m.menu.clone())
}
#[cfg_attr(target_os = "macos", allow(unused_variables))]
pub fn set_menu(&self, menu: Menu<R>) -> crate::Result<Option<Menu<R>>> {
let prev_menu = self.remove_menu()?;
self.manager.menu.insert_menu_into_stash(&menu);
let window = self.clone();
let menu_ = menu.clone();
self.run_on_main_thread(move || {
#[cfg(windows)]
if let Ok(hwnd) = window.hwnd() {
let theme = window
.theme()
.map(crate::menu::map_to_menu_theme)
.unwrap_or(muda::MenuTheme::Auto);
let _ = unsafe { menu_.inner().init_for_hwnd_with_theme(hwnd.0 as _, theme) };
}
#[cfg(any(
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd"
))]
if let (Ok(gtk_window), Ok(gtk_box)) = (window.gtk_window(), window.default_vbox()) {
let _ = menu_
.inner()
.init_for_gtk_window(>k_window, Some(>k_box));
}
})?;
self.menu_lock().replace(WindowMenu {
is_app_wide: false,
menu,
});
Ok(prev_menu)
}
pub fn remove_menu(&self) -> crate::Result<Option<Menu<R>>> {
let prev_menu = self.menu_lock().take().map(|m| m.menu);
#[cfg_attr(target_os = "macos", allow(unused_variables))]
if let Some(menu) = &prev_menu {
let window = self.clone();
let menu = menu.clone();
self.run_on_main_thread(move || {
#[cfg(windows)]
if let Ok(hwnd) = window.hwnd() {
let _ = unsafe { menu.inner().remove_for_hwnd(hwnd.0 as _) };
}
#[cfg(any(
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd"
))]
if let Ok(gtk_window) = window.gtk_window() {
let _ = menu.inner().remove_for_gtk_window(>k_window);
}
})?;
}
self
.manager
.remove_menu_from_stash_by_id(prev_menu.as_ref().map(|m| m.id()));
Ok(prev_menu)
}
pub fn hide_menu(&self) -> crate::Result<()> {
#[cfg_attr(target_os = "macos", allow(unused_variables))]
if let Some(window_menu) = &*self.menu_lock() {
let window = self.clone();
let menu_ = window_menu.menu.clone();
self.run_on_main_thread(move || {
#[cfg(windows)]
if let Ok(hwnd) = window.hwnd() {
let _ = unsafe { menu_.inner().hide_for_hwnd(hwnd.0 as _) };
}
#[cfg(any(
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd"
))]
if let Ok(gtk_window) = window.gtk_window() {
let _ = menu_.inner().hide_for_gtk_window(>k_window);
}
})?;
}
Ok(())
}
pub fn show_menu(&self) -> crate::Result<()> {
#[cfg_attr(target_os = "macos", allow(unused_variables))]
if let Some(window_menu) = &*self.menu_lock() {
let window = self.clone();
let menu_ = window_menu.menu.clone();
self.run_on_main_thread(move || {
#[cfg(windows)]
if let Ok(hwnd) = window.hwnd() {
let _ = unsafe { menu_.inner().show_for_hwnd(hwnd.0 as _) };
}
#[cfg(any(
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd"
))]
if let Ok(gtk_window) = window.gtk_window() {
let _ = menu_.inner().show_for_gtk_window(>k_window);
}
})?;
}
Ok(())
}
pub fn is_menu_visible(&self) -> crate::Result<bool> {
#[cfg_attr(target_os = "macos", allow(unused_variables))]
if let Some(window_menu) = &*self.menu_lock() {
let (tx, rx) = std::sync::mpsc::channel();
let window = self.clone();
let menu_ = window_menu.menu.clone();
self.run_on_main_thread(move || {
#[cfg(windows)]
if let Ok(hwnd) = window.hwnd() {
let _ = tx.send(unsafe { menu_.inner().is_visible_on_hwnd(hwnd.0 as _) });
}
#[cfg(any(
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd"
))]
if let Ok(gtk_window) = window.gtk_window() {
let _ = tx.send(menu_.inner().is_visible_on_gtk_window(>k_window));
}
})?;
return Ok(rx.recv().unwrap_or(false));
}
Ok(false)
}
pub fn popup_menu<M: ContextMenu>(&self, menu: &M) -> crate::Result<()> {
menu.popup(self.clone())
}
pub fn popup_menu_at<M: ContextMenu, P: Into<Position>>(
&self,
menu: &M,
position: P,
) -> crate::Result<()> {
menu.popup_at(self.clone(), position)
}
}
impl<R: Runtime> Window<R> {
pub fn scale_factor(&self) -> crate::Result<f64> {
self.window.dispatcher.scale_factor().map_err(Into::into)
}
pub fn inner_position(&self) -> crate::Result<PhysicalPosition<i32>> {
self.window.dispatcher.inner_position().map_err(Into::into)
}
pub fn outer_position(&self) -> crate::Result<PhysicalPosition<i32>> {
self.window.dispatcher.outer_position().map_err(Into::into)
}
pub fn inner_size(&self) -> crate::Result<PhysicalSize<u32>> {
self.window.dispatcher.inner_size().map_err(Into::into)
}
pub fn outer_size(&self) -> crate::Result<PhysicalSize<u32>> {
self.window.dispatcher.outer_size().map_err(Into::into)
}
pub fn is_fullscreen(&self) -> crate::Result<bool> {
self.window.dispatcher.is_fullscreen().map_err(Into::into)
}
pub fn is_minimized(&self) -> crate::Result<bool> {
self.window.dispatcher.is_minimized().map_err(Into::into)
}
pub fn is_maximized(&self) -> crate::Result<bool> {
self.window.dispatcher.is_maximized().map_err(Into::into)
}
pub fn is_focused(&self) -> crate::Result<bool> {
self.window.dispatcher.is_focused().map_err(Into::into)
}
pub fn is_decorated(&self) -> crate::Result<bool> {
self.window.dispatcher.is_decorated().map_err(Into::into)
}
pub fn is_resizable(&self) -> crate::Result<bool> {
self.window.dispatcher.is_resizable().map_err(Into::into)
}
pub fn is_enabled(&self) -> crate::Result<bool> {
self.window.dispatcher.is_enabled().map_err(Into::into)
}
pub fn is_maximizable(&self) -> crate::Result<bool> {
self.window.dispatcher.is_maximizable().map_err(Into::into)
}
pub fn is_minimizable(&self) -> crate::Result<bool> {
self.window.dispatcher.is_minimizable().map_err(Into::into)
}
pub fn is_closable(&self) -> crate::Result<bool> {
self.window.dispatcher.is_closable().map_err(Into::into)
}
pub fn is_visible(&self) -> crate::Result<bool> {
self.window.dispatcher.is_visible().map_err(Into::into)
}
pub fn title(&self) -> crate::Result<String> {
self.window.dispatcher.title().map_err(Into::into)
}
pub fn current_monitor(&self) -> crate::Result<Option<Monitor>> {
self
.window
.dispatcher
.current_monitor()
.map(|m| m.map(Into::into))
.map_err(Into::into)
}
pub fn monitor_from_point(&self, x: f64, y: f64) -> crate::Result<Option<Monitor>> {
self
.window
.dispatcher
.monitor_from_point(x, y)
.map(|m| m.map(Into::into))
.map_err(Into::into)
}
pub fn primary_monitor(&self) -> crate::Result<Option<Monitor>> {
self
.window
.dispatcher
.primary_monitor()
.map(|m| m.map(Into::into))
.map_err(Into::into)
}
pub fn available_monitors(&self) -> crate::Result<Vec<Monitor>> {
self
.window
.dispatcher
.available_monitors()
.map(|m| m.into_iter().map(Into::into).collect())
.map_err(Into::into)
}
#[cfg(target_os = "macos")]
pub fn ns_window(&self) -> crate::Result<*mut std::ffi::c_void> {
self
.window
.dispatcher
.window_handle()
.map_err(Into::into)
.and_then(|handle| {
if let raw_window_handle::RawWindowHandle::AppKit(h) = handle.as_raw() {
let view: &objc2_app_kit::NSView = unsafe { h.ns_view.cast().as_ref() };
let ns_window = view.window().expect("view to be installed in window");
Ok(objc2::rc::Retained::autorelease_ptr(ns_window).cast())
} else {
Err(crate::Error::InvalidWindowHandle)
}
})
}
#[cfg(target_os = "macos")]
pub fn ns_view(&self) -> crate::Result<*mut std::ffi::c_void> {
self
.window
.dispatcher
.window_handle()
.map_err(Into::into)
.and_then(|handle| {
if let raw_window_handle::RawWindowHandle::AppKit(h) = handle.as_raw() {
Ok(h.ns_view.as_ptr())
} else {
Err(crate::Error::InvalidWindowHandle)
}
})
}
#[cfg(windows)]
pub fn hwnd(&self) -> crate::Result<HWND> {
self
.window
.dispatcher
.window_handle()
.map_err(Into::into)
.and_then(|handle| {
if let raw_window_handle::RawWindowHandle::Win32(h) = handle.as_raw() {
Ok(HWND(h.hwnd.get() as _))
} else {
Err(crate::Error::InvalidWindowHandle)
}
})
}
#[cfg(any(
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd"
))]
pub fn gtk_window(&self) -> crate::Result<gtk::ApplicationWindow> {
self.window.dispatcher.gtk_window().map_err(Into::into)
}
#[cfg(any(
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd"
))]
pub fn default_vbox(&self) -> crate::Result<gtk::Box> {
self.window.dispatcher.default_vbox().map_err(Into::into)
}
pub fn theme(&self) -> crate::Result<Theme> {
self.window.dispatcher.theme().map_err(Into::into)
}
}
#[cfg(desktop)]
impl<R: Runtime> Window<R> {
pub fn cursor_position(&self) -> crate::Result<PhysicalPosition<f64>> {
self.app_handle.cursor_position()
}
}
#[cfg(desktop)]
impl<R: Runtime> Window<R> {
pub fn center(&self) -> crate::Result<()> {
self.window.dispatcher.center().map_err(Into::into)
}
pub fn request_user_attention(
&self,
request_type: Option<UserAttentionType>,
) -> crate::Result<()> {
self
.window
.dispatcher
.request_user_attention(request_type)
.map_err(Into::into)
}
pub fn set_resizable(&self, resizable: bool) -> crate::Result<()> {
self
.window
.dispatcher
.set_resizable(resizable)
.map_err(Into::into)
}
pub fn set_maximizable(&self, maximizable: bool) -> crate::Result<()> {
self
.window
.dispatcher
.set_maximizable(maximizable)
.map_err(Into::into)
}
pub fn set_minimizable(&self, minimizable: bool) -> crate::Result<()> {
self
.window
.dispatcher
.set_minimizable(minimizable)
.map_err(Into::into)
}
pub fn set_closable(&self, closable: bool) -> crate::Result<()> {
self
.window
.dispatcher
.set_closable(closable)
.map_err(Into::into)
}
pub fn set_title(&self, title: &str) -> crate::Result<()> {
self
.window
.dispatcher
.set_title(title.to_string())
.map_err(Into::into)
}
pub fn set_enabled(&self, enabled: bool) -> crate::Result<()> {
self
.window
.dispatcher
.set_enabled(enabled)
.map_err(Into::into)
}
pub fn maximize(&self) -> crate::Result<()> {
self.window.dispatcher.maximize().map_err(Into::into)
}
pub fn unmaximize(&self) -> crate::Result<()> {
self.window.dispatcher.unmaximize().map_err(Into::into)
}
pub fn minimize(&self) -> crate::Result<()> {
self.window.dispatcher.minimize().map_err(Into::into)
}
pub fn unminimize(&self) -> crate::Result<()> {
self.window.dispatcher.unminimize().map_err(Into::into)
}
pub fn show(&self) -> crate::Result<()> {
self.window.dispatcher.show().map_err(Into::into)
}
pub fn hide(&self) -> crate::Result<()> {
self.window.dispatcher.hide().map_err(Into::into)
}
pub fn close(&self) -> crate::Result<()> {
self.window.dispatcher.close().map_err(Into::into)
}
pub fn destroy(&self) -> crate::Result<()> {
self.window.dispatcher.destroy().map_err(Into::into)
}
pub fn set_decorations(&self, decorations: bool) -> crate::Result<()> {
self
.window
.dispatcher
.set_decorations(decorations)
.map_err(Into::into)
}
pub fn set_shadow(&self, enable: bool) -> crate::Result<()> {
self
.window
.dispatcher
.set_shadow(enable)
.map_err(Into::into)
}
#[cfg_attr(
feature = "unstable",
doc = r####"
```rust,no_run
use tauri::{Manager, window::{Color, Effect, EffectState, EffectsBuilder}};
tauri::Builder::default()
.setup(|app| {
let window = app.get_window("main").unwrap();
window.set_effects(
EffectsBuilder::new()
.effect(Effect::Popover)
.state(EffectState::Active)
.radius(5.)
.color(Color(0, 0, 0, 255))
.build(),
)?;
Ok(())
});
```
"####
)]
pub fn set_effects<E: Into<Option<WindowEffectsConfig>>>(&self, effects: E) -> crate::Result<()> {
let effects = effects.into();
let window = self.clone();
self.run_on_main_thread(move || {
let _ = crate::vibrancy::set_window_effects(&window, effects);
})
}
pub fn set_always_on_bottom(&self, always_on_bottom: bool) -> crate::Result<()> {
self
.window
.dispatcher
.set_always_on_bottom(always_on_bottom)
.map_err(Into::into)
}
pub fn set_always_on_top(&self, always_on_top: bool) -> crate::Result<()> {
self
.window
.dispatcher
.set_always_on_top(always_on_top)
.map_err(Into::into)
}
pub fn set_visible_on_all_workspaces(
&self,
visible_on_all_workspaces: bool,
) -> crate::Result<()> {
self
.window
.dispatcher
.set_visible_on_all_workspaces(visible_on_all_workspaces)
.map_err(Into::into)
}
pub fn set_background_color(&self, color: Option<Color>) -> crate::Result<()> {
self
.window
.dispatcher
.set_background_color(color)
.map_err(Into::into)
}
pub fn set_content_protected(&self, protected: bool) -> crate::Result<()> {
self
.window
.dispatcher
.set_content_protected(protected)
.map_err(Into::into)
}
pub fn set_size<S: Into<Size>>(&self, size: S) -> crate::Result<()> {
self
.window
.dispatcher
.set_size(size.into())
.map_err(Into::into)
}
pub fn set_min_size<S: Into<Size>>(&self, size: Option<S>) -> crate::Result<()> {
self
.window
.dispatcher
.set_min_size(size.map(|s| s.into()))
.map_err(Into::into)
}
pub fn set_max_size<S: Into<Size>>(&self, size: Option<S>) -> crate::Result<()> {
self
.window
.dispatcher
.set_max_size(size.map(|s| s.into()))
.map_err(Into::into)
}
pub fn set_size_constraints(
&self,
constriants: tauri_runtime::window::WindowSizeConstraints,
) -> crate::Result<()> {
self
.window
.dispatcher
.set_size_constraints(constriants)
.map_err(Into::into)
}
pub fn set_position<Pos: Into<Position>>(&self, position: Pos) -> crate::Result<()> {
self
.window
.dispatcher
.set_position(position.into())
.map_err(Into::into)
}
pub fn set_fullscreen(&self, fullscreen: bool) -> crate::Result<()> {
self
.window
.dispatcher
.set_fullscreen(fullscreen)
.map_err(Into::into)
}
pub fn set_focus(&self) -> crate::Result<()> {
self.window.dispatcher.set_focus().map_err(Into::into)
}
pub fn set_icon(&self, icon: Image<'_>) -> crate::Result<()> {
self
.window
.dispatcher
.set_icon(icon.into())
.map_err(Into::into)
}
pub fn set_skip_taskbar(&self, skip: bool) -> crate::Result<()> {
self
.window
.dispatcher
.set_skip_taskbar(skip)
.map_err(Into::into)
}
pub fn set_cursor_grab(&self, grab: bool) -> crate::Result<()> {
self
.window
.dispatcher
.set_cursor_grab(grab)
.map_err(Into::into)
}
pub fn set_cursor_visible(&self, visible: bool) -> crate::Result<()> {
self
.window
.dispatcher
.set_cursor_visible(visible)
.map_err(Into::into)
}
pub fn set_cursor_icon(&self, icon: CursorIcon) -> crate::Result<()> {
self
.window
.dispatcher
.set_cursor_icon(icon)
.map_err(Into::into)
}
pub fn set_cursor_position<Pos: Into<Position>>(&self, position: Pos) -> crate::Result<()> {
self
.window
.dispatcher
.set_cursor_position(position)
.map_err(Into::into)
}
pub fn set_ignore_cursor_events(&self, ignore: bool) -> crate::Result<()> {
self
.window
.dispatcher
.set_ignore_cursor_events(ignore)
.map_err(Into::into)
}
pub fn start_dragging(&self) -> crate::Result<()> {
self.window.dispatcher.start_dragging().map_err(Into::into)
}
pub fn start_resize_dragging(
&self,
direction: tauri_runtime::ResizeDirection,
) -> crate::Result<()> {
self
.window
.dispatcher
.start_resize_dragging(direction)
.map_err(Into::into)
}
#[cfg(target_os = "windows")]
#[cfg_attr(docsrs, doc(cfg(target_os = "windows")))]
pub fn set_overlay_icon(&self, icon: Option<Image<'_>>) -> crate::Result<()> {
self
.window
.dispatcher
.set_overlay_icon(icon.map(|x| x.into()))
.map_err(Into::into)
}
pub fn set_badge_count(&self, count: Option<i64>) -> crate::Result<()> {
self
.window
.dispatcher
.set_badge_count(count, Some(format!("{}.desktop", self.package_info().name)))
.map_err(Into::into)
}
#[cfg(target_os = "macos")]
#[cfg_attr(docsrs, doc(cfg(target_os = "macos")))]
pub fn set_badge_label(&self, label: Option<String>) -> crate::Result<()> {
self
.window
.dispatcher
.set_badge_label(label)
.map_err(Into::into)
}
pub fn set_progress_bar(&self, progress_state: ProgressBarState) -> crate::Result<()> {
self
.window
.dispatcher
.set_progress_bar(crate::runtime::ProgressBarState {
status: progress_state.status,
progress: progress_state.progress,
desktop_filename: Some(format!("{}.desktop", self.package_info().name)),
})
.map_err(Into::into)
}
pub fn set_title_bar_style(&self, style: tauri_utils::TitleBarStyle) -> crate::Result<()> {
self
.window
.dispatcher
.set_title_bar_style(style)
.map_err(Into::into)
}
pub fn set_theme(&self, theme: Option<Theme>) -> crate::Result<()> {
self
.window
.dispatcher
.set_theme(theme)
.map_err(Into::<crate::Error>::into)?;
#[cfg(windows)]
if let (Some(menu), Ok(hwnd)) = (self.menu(), self.hwnd()) {
let raw_hwnd = hwnd.0 as isize;
self.run_on_main_thread(move || {
let _ = unsafe {
menu.inner().set_theme_for_hwnd(
raw_hwnd,
theme
.map(crate::menu::map_to_menu_theme)
.unwrap_or(muda::MenuTheme::Auto),
)
};
})?;
};
Ok(())
}
}
#[cfg(desktop)]
#[cfg_attr(
docsrs,
doc(cfg(any(target_os = "macos", target_os = "linux", windows)))
)]
#[derive(serde::Deserialize, Debug)]
pub struct ProgressBarState {
pub status: Option<ProgressBarStatus>,
pub progress: Option<u64>,
}
impl<R: Runtime> Listener<R> for Window<R> {
#[cfg_attr(
feature = "unstable",
doc = r####"
```
use tauri::{Manager, Listener};
tauri::Builder::default()
.setup(|app| {
let window = app.get_window("main").unwrap();
window.listen("component-loaded", move |event| {
println!("window just loaded a component");
});
Ok(())
});
```
"####
)]
fn listen<F>(&self, event: impl Into<String>, handler: F) -> EventId
where
F: Fn(Event) + Send + 'static,
{
self.manager.listen(
event.into(),
EventTarget::Window {
label: self.label().to_string(),
},
handler,
)
}
fn once<F>(&self, event: impl Into<String>, handler: F) -> EventId
where
F: FnOnce(Event) + Send + 'static,
{
self.manager.once(
event.into(),
EventTarget::Window {
label: self.label().to_string(),
},
handler,
)
}
#[cfg_attr(
feature = "unstable",
doc = r####"
```
use tauri::{Manager, Listener};
tauri::Builder::default()
.setup(|app| {
let window = app.get_window("main").unwrap();
let window_ = window.clone();
let handler = window.listen("component-loaded", move |event| {
println!("window just loaded a component");
// we no longer need to listen to the event
// we also could have used `window.once` instead
window_.unlisten(event.id());
});
// stop listening to the event when you do not need it anymore
window.unlisten(handler);
Ok(())
});
```
"####
)]
fn unlisten(&self, id: EventId) {
self.manager.unlisten(id)
}
}
impl<R: Runtime> Emitter<R> for Window<R> {
#[cfg_attr(
feature = "unstable",
doc = r####"
```
use tauri::Emitter;
#[tauri::command]
fn synchronize(window: tauri::Window) {
// emits the synchronized event to all webviews
window.emit("synchronized", ());
}
```
"####
)]
fn emit<S: Serialize + Clone>(&self, event: &str, payload: S) -> crate::Result<()> {
self.manager.emit(event, payload)
}
#[cfg_attr(
feature = "unstable",
doc = r####"
```
use tauri::{Emitter, EventTarget};
#[tauri::command]
fn download(window: tauri::Window) {
for i in 1..100 {
std::thread::sleep(std::time::Duration::from_millis(150));
// emit a download progress event to all listeners
window.emit_to(EventTarget::any(), "download-progress", i);
// emit an event to listeners that used App::listen or AppHandle::listen
window.emit_to(EventTarget::app(), "download-progress", i);
// emit an event to any webview/window/webviewWindow matching the given label
window.emit_to("updater", "download-progress", i); // similar to using EventTarget::labeled
window.emit_to(EventTarget::labeled("updater"), "download-progress", i);
// emit an event to listeners that used WebviewWindow::listen
window.emit_to(EventTarget::webview_window("updater"), "download-progress", i);
}
}
```
"####
)]
fn emit_to<I, S>(&self, target: I, event: &str, payload: S) -> crate::Result<()>
where
I: Into<EventTarget>,
S: Serialize + Clone,
{
self.manager.emit_to(target, event, payload)
}
#[cfg_attr(
feature = "unstable",
doc = r####"
```
use tauri::{Emitter, EventTarget};
#[tauri::command]
fn download(window: tauri::Window) {
for i in 1..100 {
std::thread::sleep(std::time::Duration::from_millis(150));
// emit a download progress event to the updater window
window.emit_filter("download-progress", i, |t| match t {
EventTarget::WebviewWindow { label } => label == "main",
_ => false,
});
}
}
```
"####
)]
fn emit_filter<S, F>(&self, event: &str, payload: S, filter: F) -> crate::Result<()>
where
S: Serialize + Clone,
F: Fn(&EventTarget) -> bool,
{
self.manager.emit_filter(event, payload, filter)
}
}
#[derive(Default)]
pub struct EffectsBuilder(WindowEffectsConfig);
impl EffectsBuilder {
pub fn new() -> Self {
Self(WindowEffectsConfig::default())
}
pub fn effect(mut self, effect: Effect) -> Self {
self.0.effects.push(effect);
self
}
pub fn effects<I: IntoIterator<Item = Effect>>(mut self, effects: I) -> Self {
self.0.effects.extend(effects);
self
}
pub fn clear_effects(mut self) -> Self {
self.0.effects.clear();
self
}
pub fn state(mut self, state: EffectState) -> Self {
self.0.state = Some(state);
self
}
pub fn radius(mut self, radius: f64) -> Self {
self.0.radius = Some(radius);
self
}
pub fn color(mut self, color: Color) -> Self {
self.0.color = Some(color);
self
}
pub fn build(self) -> WindowEffectsConfig {
self.0
}
}
impl From<WindowEffectsConfig> for EffectsBuilder {
fn from(value: WindowEffectsConfig) -> Self {
Self(value)
}
}
#[cfg(test)]
mod tests {
#[test]
fn window_is_send_sync() {
crate::test_utils::assert_send::<super::Window>();
crate::test_utils::assert_sync::<super::Window>();
}
}