44
55//! The [`wry`] Tauri [`Runtime`].
66
7+ use raw_window_handle:: HasRawWindowHandle ;
78use tauri_runtime:: {
89 http:: {
910 Request as HttpRequest , RequestParts as HttpRequestParts , Response as HttpResponse ,
@@ -976,18 +977,6 @@ impl From<FileDropEventWrapper> for FileDropEvent {
976977 }
977978}
978979
979- #[ cfg( target_os = "macos" ) ]
980- pub struct NSWindow ( * mut std:: ffi:: c_void ) ;
981- #[ cfg( target_os = "macos" ) ]
982- #[ allow( clippy:: non_send_fields_in_send_ty) ]
983- unsafe impl Send for NSWindow { }
984-
985- #[ cfg( windows) ]
986- pub struct Hwnd ( HWND ) ;
987- #[ cfg( windows) ]
988- #[ allow( clippy:: non_send_fields_in_send_ty) ]
989- unsafe impl Send for Hwnd { }
990-
991980#[ cfg( any(
992981 target_os = "linux" ,
993982 target_os = "dragonfly" ,
@@ -1006,6 +995,9 @@ pub struct GtkWindow(gtk::ApplicationWindow);
1006995#[ allow( clippy:: non_send_fields_in_send_ty) ]
1007996unsafe impl Send for GtkWindow { }
1008997
998+ pub struct RawWindowHandle ( raw_window_handle:: RawWindowHandle ) ;
999+ unsafe impl Send for RawWindowHandle { }
1000+
10091001pub enum WindowMessage {
10101002 WithWebview ( Box < dyn FnOnce ( Webview ) + Send > ) ,
10111003 // Devtools
@@ -1030,10 +1022,6 @@ pub enum WindowMessage {
10301022 CurrentMonitor ( Sender < Option < MonitorHandle > > ) ,
10311023 PrimaryMonitor ( Sender < Option < MonitorHandle > > ) ,
10321024 AvailableMonitors ( Sender < Vec < MonitorHandle > > ) ,
1033- #[ cfg( target_os = "macos" ) ]
1034- NSWindow ( Sender < NSWindow > ) ,
1035- #[ cfg( windows) ]
1036- Hwnd ( Sender < Hwnd > ) ,
10371025 #[ cfg( any(
10381026 target_os = "linux" ,
10391027 target_os = "dragonfly" ,
@@ -1042,6 +1030,7 @@ pub enum WindowMessage {
10421030 target_os = "openbsd"
10431031 ) ) ]
10441032 GtkWindow ( Sender < GtkWindow > ) ,
1033+ RawWindowHandle ( Sender < RawWindowHandle > ) ,
10451034 Theme ( Sender < Theme > ) ,
10461035 // Setters
10471036 Center ( Sender < Result < ( ) > > ) ,
@@ -1285,16 +1274,6 @@ impl<T: UserEvent> Dispatch<T> for WryDispatcher<T> {
12851274 )
12861275 }
12871276
1288- #[ cfg( target_os = "macos" ) ]
1289- fn ns_window ( & self ) -> Result < * mut std:: ffi:: c_void > {
1290- window_getter ! ( self , WindowMessage :: NSWindow ) . map ( |w| w. 0 )
1291- }
1292-
1293- #[ cfg( windows) ]
1294- fn hwnd ( & self ) -> Result < HWND > {
1295- window_getter ! ( self , WindowMessage :: Hwnd ) . map ( |w| w. 0 )
1296- }
1297-
12981277 fn theme ( & self ) -> Result < Theme > {
12991278 window_getter ! ( self , WindowMessage :: Theme )
13001279 }
@@ -1311,6 +1290,10 @@ impl<T: UserEvent> Dispatch<T> for WryDispatcher<T> {
13111290 window_getter ! ( self , WindowMessage :: GtkWindow ) . map ( |w| w. 0 )
13121291 }
13131292
1293+ fn raw_window_handle ( & self ) -> Result < raw_window_handle:: RawWindowHandle > {
1294+ window_getter ! ( self , WindowMessage :: RawWindowHandle ) . map ( |w| w. 0 )
1295+ }
1296+
13141297 // Setters
13151298
13161299 fn center ( & self ) -> Result < ( ) > {
@@ -2330,10 +2313,6 @@ fn handle_user_message<T: UserEvent>(
23302313 WindowMessage :: AvailableMonitors ( tx) => {
23312314 tx. send ( window. available_monitors ( ) . collect ( ) ) . unwrap ( )
23322315 }
2333- #[ cfg( target_os = "macos" ) ]
2334- WindowMessage :: NSWindow ( tx) => tx. send ( NSWindow ( window. ns_window ( ) ) ) . unwrap ( ) ,
2335- #[ cfg( windows) ]
2336- WindowMessage :: Hwnd ( tx) => tx. send ( Hwnd ( HWND ( window. hwnd ( ) as _ ) ) ) . unwrap ( ) ,
23372316 #[ cfg( any(
23382317 target_os = "linux" ,
23392318 target_os = "dragonfly" ,
@@ -2344,6 +2323,9 @@ fn handle_user_message<T: UserEvent>(
23442323 WindowMessage :: GtkWindow ( tx) => {
23452324 tx. send ( GtkWindow ( window. gtk_window ( ) . clone ( ) ) ) . unwrap ( )
23462325 }
2326+ WindowMessage :: RawWindowHandle ( tx) => tx
2327+ . send ( RawWindowHandle ( window. raw_window_handle ( ) ) )
2328+ . unwrap ( ) ,
23472329 WindowMessage :: Theme ( tx) => {
23482330 #[ cfg( any( windows, target_os = "macos" ) ) ]
23492331 tx. send ( map_theme ( & window. theme ( ) ) ) . unwrap ( ) ;
0 commit comments