@@ -50,15 +50,15 @@ use wry::{
50
50
event_loop:: { ControlFlow , EventLoop , EventLoopProxy , EventLoopWindowTarget } ,
51
51
global_shortcut:: { GlobalShortcut , ShortcutManager as WryShortcutManager } ,
52
52
monitor:: MonitorHandle ,
53
- window:: { Fullscreen , Icon as WindowIcon , UserAttentionType as WryUserAttentionType , WindowId } ,
53
+ window:: { Fullscreen , Icon as WindowIcon , UserAttentionType as WryUserAttentionType } ,
54
54
} ,
55
55
webview:: {
56
56
FileDropEvent as WryFileDropEvent , RpcRequest as WryRpcRequest , RpcResponse , WebContext ,
57
57
WebView , WebViewBuilder ,
58
58
} ,
59
59
} ;
60
60
61
- pub use wry:: application:: window:: { Window , WindowBuilder as WryWindowBuilder } ;
61
+ pub use wry:: application:: window:: { Window , WindowBuilder as WryWindowBuilder , WindowId } ;
62
62
63
63
#[ cfg( target_os = "windows" ) ]
64
64
use wry:: webview:: WebviewExtWindows ;
@@ -134,7 +134,7 @@ struct EventLoopContext {
134
134
}
135
135
136
136
#[ derive( Debug , Clone ) ]
137
- struct GlobalShortcutWrapper ( GlobalShortcut ) ;
137
+ pub struct GlobalShortcutWrapper ( GlobalShortcut ) ;
138
138
139
139
unsafe impl Send for GlobalShortcutWrapper { }
140
140
@@ -412,7 +412,7 @@ impl From<Position> for PositionWrapper {
412
412
}
413
413
414
414
#[ derive( Debug , Clone ) ]
415
- struct UserAttentionTypeWrapper ( WryUserAttentionType ) ;
415
+ pub struct UserAttentionTypeWrapper ( WryUserAttentionType ) ;
416
416
417
417
impl From < UserAttentionType > for UserAttentionTypeWrapper {
418
418
fn from ( request_type : UserAttentionType ) -> UserAttentionTypeWrapper {
@@ -626,12 +626,12 @@ impl From<FileDropEventWrapper> for FileDropEvent {
626
626
}
627
627
628
628
#[ cfg( target_os = "macos" ) ]
629
- struct NSWindow ( * mut std:: ffi:: c_void ) ;
629
+ pub struct NSWindow ( * mut std:: ffi:: c_void ) ;
630
630
#[ cfg( target_os = "macos" ) ]
631
631
unsafe impl Send for NSWindow { }
632
632
633
633
#[ cfg( windows) ]
634
- struct Hwnd ( HWND ) ;
634
+ pub struct Hwnd ( HWND ) ;
635
635
#[ cfg( windows) ]
636
636
unsafe impl Send for Hwnd { }
637
637
@@ -642,7 +642,7 @@ unsafe impl Send for Hwnd {}
642
642
target_os = "netbsd" ,
643
643
target_os = "openbsd"
644
644
) ) ]
645
- struct GtkWindow ( gtk:: ApplicationWindow ) ;
645
+ pub struct GtkWindow ( gtk:: ApplicationWindow ) ;
646
646
#[ cfg( any(
647
647
target_os = "linux" ,
648
648
target_os = "dragonfly" ,
@@ -653,7 +653,7 @@ struct GtkWindow(gtk::ApplicationWindow);
653
653
unsafe impl Send for GtkWindow { }
654
654
655
655
#[ derive( Debug , Clone ) ]
656
- enum WindowMessage {
656
+ pub enum WindowMessage {
657
657
// Getters
658
658
ScaleFactor ( Sender < f64 > ) ,
659
659
InnerPosition ( Sender < Result < PhysicalPosition < i32 > > > ) ,
@@ -714,7 +714,7 @@ enum WindowMessage {
714
714
}
715
715
716
716
#[ derive( Debug , Clone ) ]
717
- enum WebviewMessage {
717
+ pub enum WebviewMessage {
718
718
EvaluateScript ( String ) ,
719
719
#[ allow( dead_code) ]
720
720
WebviewEvent ( WebviewEvent ) ,
@@ -723,34 +723,34 @@ enum WebviewMessage {
723
723
724
724
#[ allow( dead_code) ]
725
725
#[ derive( Debug , Clone ) ]
726
- enum WebviewEvent {
726
+ pub enum WebviewEvent {
727
727
Focused ( bool ) ,
728
728
}
729
729
730
730
#[ cfg( feature = "system-tray" ) ]
731
731
#[ derive( Clone ) ]
732
- pub ( crate ) enum TrayMessage {
732
+ pub enum TrayMessage {
733
733
UpdateItem ( u16 , menu:: MenuUpdate ) ,
734
734
UpdateIcon ( Icon ) ,
735
735
#[ cfg( target_os = "macos" ) ]
736
736
UpdateIconAsTemplate ( bool ) ,
737
737
}
738
738
739
739
#[ derive( Clone ) ]
740
- pub ( crate ) enum GlobalShortcutMessage {
740
+ pub enum GlobalShortcutMessage {
741
741
IsRegistered ( Accelerator , Sender < bool > ) ,
742
742
Register ( Accelerator , Sender < Result < GlobalShortcutWrapper > > ) ,
743
743
Unregister ( GlobalShortcutWrapper , Sender < Result < ( ) > > ) ,
744
744
UnregisterAll ( Sender < Result < ( ) > > ) ,
745
745
}
746
746
747
747
#[ derive( Clone ) ]
748
- pub ( crate ) enum ClipboardMessage {
748
+ pub enum ClipboardMessage {
749
749
WriteText ( String , Sender < ( ) > ) ,
750
750
ReadText ( Sender < Option < String > > ) ,
751
751
}
752
752
753
- pub ( crate ) enum Message {
753
+ pub enum Message {
754
754
Task ( Box < dyn FnOnce ( ) + Send > ) ,
755
755
Window ( WindowId , WindowMessage ) ,
756
756
Webview ( WindowId , WebviewMessage ) ,
@@ -1235,7 +1235,7 @@ impl WindowHandle {
1235
1235
}
1236
1236
}
1237
1237
1238
- struct WindowWrapper {
1238
+ pub struct WindowWrapper {
1239
1239
label : String ,
1240
1240
inner : WindowHandle ,
1241
1241
#[ cfg( feature = "menu" ) ]
@@ -1280,6 +1280,16 @@ impl WryHandle {
1280
1280
. map_err ( |_| Error :: FailedToSendMessage ) ?;
1281
1281
rx. recv ( ) . unwrap ( )
1282
1282
}
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
+ }
1283
1293
}
1284
1294
1285
1295
impl RuntimeHandle for WryHandle {
0 commit comments