@@ -50,15 +50,15 @@ use wry::{
5050 event_loop:: { ControlFlow , EventLoop , EventLoopProxy , EventLoopWindowTarget } ,
5151 global_shortcut:: { GlobalShortcut , ShortcutManager as WryShortcutManager } ,
5252 monitor:: MonitorHandle ,
53- window:: { Fullscreen , Icon as WindowIcon , UserAttentionType as WryUserAttentionType , WindowId } ,
53+ window:: { Fullscreen , Icon as WindowIcon , UserAttentionType as WryUserAttentionType } ,
5454 } ,
5555 webview:: {
5656 FileDropEvent as WryFileDropEvent , RpcRequest as WryRpcRequest , RpcResponse , WebContext ,
5757 WebView , WebViewBuilder ,
5858 } ,
5959} ;
6060
61- pub use wry:: application:: window:: { Window , WindowBuilder as WryWindowBuilder } ;
61+ pub use wry:: application:: window:: { Window , WindowBuilder as WryWindowBuilder , WindowId } ;
6262
6363#[ cfg( target_os = "windows" ) ]
6464use wry:: webview:: WebviewExtWindows ;
@@ -134,7 +134,7 @@ struct EventLoopContext {
134134}
135135
136136#[ derive( Debug , Clone ) ]
137- struct GlobalShortcutWrapper ( GlobalShortcut ) ;
137+ pub struct GlobalShortcutWrapper ( GlobalShortcut ) ;
138138
139139unsafe impl Send for GlobalShortcutWrapper { }
140140
@@ -412,7 +412,7 @@ impl From<Position> for PositionWrapper {
412412}
413413
414414#[ derive( Debug , Clone ) ]
415- struct UserAttentionTypeWrapper ( WryUserAttentionType ) ;
415+ pub struct UserAttentionTypeWrapper ( WryUserAttentionType ) ;
416416
417417impl From < UserAttentionType > for UserAttentionTypeWrapper {
418418 fn from ( request_type : UserAttentionType ) -> UserAttentionTypeWrapper {
@@ -626,12 +626,12 @@ impl From<FileDropEventWrapper> for FileDropEvent {
626626}
627627
628628#[ cfg( target_os = "macos" ) ]
629- struct NSWindow ( * mut std:: ffi:: c_void ) ;
629+ pub struct NSWindow ( * mut std:: ffi:: c_void ) ;
630630#[ cfg( target_os = "macos" ) ]
631631unsafe impl Send for NSWindow { }
632632
633633#[ cfg( windows) ]
634- struct Hwnd ( HWND ) ;
634+ pub struct Hwnd ( HWND ) ;
635635#[ cfg( windows) ]
636636unsafe impl Send for Hwnd { }
637637
@@ -642,7 +642,7 @@ unsafe impl Send for Hwnd {}
642642 target_os = "netbsd" ,
643643 target_os = "openbsd"
644644) ) ]
645- struct GtkWindow ( gtk:: ApplicationWindow ) ;
645+ pub struct GtkWindow ( gtk:: ApplicationWindow ) ;
646646#[ cfg( any(
647647 target_os = "linux" ,
648648 target_os = "dragonfly" ,
@@ -653,7 +653,7 @@ struct GtkWindow(gtk::ApplicationWindow);
653653unsafe impl Send for GtkWindow { }
654654
655655#[ derive( Debug , Clone ) ]
656- enum WindowMessage {
656+ pub enum WindowMessage {
657657 // Getters
658658 ScaleFactor ( Sender < f64 > ) ,
659659 InnerPosition ( Sender < Result < PhysicalPosition < i32 > > > ) ,
@@ -714,7 +714,7 @@ enum WindowMessage {
714714}
715715
716716#[ derive( Debug , Clone ) ]
717- enum WebviewMessage {
717+ pub enum WebviewMessage {
718718 EvaluateScript ( String ) ,
719719 #[ allow( dead_code) ]
720720 WebviewEvent ( WebviewEvent ) ,
@@ -723,34 +723,34 @@ enum WebviewMessage {
723723
724724#[ allow( dead_code) ]
725725#[ derive( Debug , Clone ) ]
726- enum WebviewEvent {
726+ pub enum WebviewEvent {
727727 Focused ( bool ) ,
728728}
729729
730730#[ cfg( feature = "system-tray" ) ]
731731#[ derive( Clone ) ]
732- pub ( crate ) enum TrayMessage {
732+ pub enum TrayMessage {
733733 UpdateItem ( u16 , menu:: MenuUpdate ) ,
734734 UpdateIcon ( Icon ) ,
735735 #[ cfg( target_os = "macos" ) ]
736736 UpdateIconAsTemplate ( bool ) ,
737737}
738738
739739#[ derive( Clone ) ]
740- pub ( crate ) enum GlobalShortcutMessage {
740+ pub enum GlobalShortcutMessage {
741741 IsRegistered ( Accelerator , Sender < bool > ) ,
742742 Register ( Accelerator , Sender < Result < GlobalShortcutWrapper > > ) ,
743743 Unregister ( GlobalShortcutWrapper , Sender < Result < ( ) > > ) ,
744744 UnregisterAll ( Sender < Result < ( ) > > ) ,
745745}
746746
747747#[ derive( Clone ) ]
748- pub ( crate ) enum ClipboardMessage {
748+ pub enum ClipboardMessage {
749749 WriteText ( String , Sender < ( ) > ) ,
750750 ReadText ( Sender < Option < String > > ) ,
751751}
752752
753- pub ( crate ) enum Message {
753+ pub enum Message {
754754 Task ( Box < dyn FnOnce ( ) + Send > ) ,
755755 Window ( WindowId , WindowMessage ) ,
756756 Webview ( WindowId , WebviewMessage ) ,
@@ -1235,7 +1235,7 @@ impl WindowHandle {
12351235 }
12361236}
12371237
1238- struct WindowWrapper {
1238+ pub struct WindowWrapper {
12391239 label : String ,
12401240 inner : WindowHandle ,
12411241 #[ cfg( feature = "menu" ) ]
@@ -1280,6 +1280,16 @@ impl WryHandle {
12801280 . map_err ( |_| Error :: FailedToSendMessage ) ?;
12811281 rx. recv ( ) . unwrap ( )
12821282 }
1283+
1284+ /// Send a message to the event loop.
1285+ pub fn send_event ( & self , message : Message ) -> Result < ( ) > {
1286+ self
1287+ . dispatcher_context
1288+ . proxy
1289+ . send_event ( message)
1290+ . map_err ( |_| Error :: FailedToSendMessage ) ?;
1291+ Ok ( ( ) )
1292+ }
12831293}
12841294
12851295impl RuntimeHandle for WryHandle {
0 commit comments