From 75f5cb4015f72745161110ad0076cf4945411a6d Mon Sep 17 00:00:00 2001 From: Fabian-Lars Date: Tue, 19 Mar 2024 13:43:15 +0100 Subject: [PATCH] feat(core): Implement HasDisplayHandle for Window (#9214) --- .changes/core-window-hasdisplayhandle.md | 5 +++++ core/tauri/src/webview/webview_window.rs | 8 ++++++++ core/tauri/src/window/mod.rs | 8 ++++++++ 3 files changed, 21 insertions(+) create mode 100644 .changes/core-window-hasdisplayhandle.md diff --git a/.changes/core-window-hasdisplayhandle.md b/.changes/core-window-hasdisplayhandle.md new file mode 100644 index 000000000..a2b1346d3 --- /dev/null +++ b/.changes/core-window-hasdisplayhandle.md @@ -0,0 +1,5 @@ +--- +tauri: 'patch:enhance' +--- + +`tauri::Window` and `tauri::WebviewWindow` now implement `raw_window_handle::HasDisplayHandle`. diff --git a/core/tauri/src/webview/webview_window.rs b/core/tauri/src/webview/webview_window.rs index 0b78c5215..7a000193e 100644 --- a/core/tauri/src/webview/webview_window.rs +++ b/core/tauri/src/webview/webview_window.rs @@ -876,6 +876,14 @@ impl raw_window_handle::HasWindowHandle for WebviewWindow { } } +impl raw_window_handle::HasDisplayHandle for WebviewWindow { + fn display_handle( + &self, + ) -> std::result::Result, raw_window_handle::HandleError> { + self.webview.app_handle.display_handle() + } +} + impl<'de, R: Runtime> CommandArg<'de, R> for WebviewWindow { /// Grabs the [`Window`] from the [`CommandItem`]. This will never fail. fn from_command(command: CommandItem<'de, R>) -> Result { diff --git a/core/tauri/src/window/mod.rs b/core/tauri/src/window/mod.rs index cf5bd449c..ead6cce1d 100644 --- a/core/tauri/src/window/mod.rs +++ b/core/tauri/src/window/mod.rs @@ -885,6 +885,14 @@ impl raw_window_handle::HasWindowHandle for Window { } } +impl raw_window_handle::HasDisplayHandle for Window { + fn display_handle( + &self, + ) -> std::result::Result, raw_window_handle::HandleError> { + self.app_handle.display_handle() + } +} + impl Clone for Window { fn clone(&self) -> Self { Self {