@@ -63,7 +63,7 @@ pub(crate) type GlobalMenuEventListener<T> = Box<dyn Fn(&T, crate::menu::MenuEve
63
63
#[ cfg( all( desktop, feature = "tray-icon" ) ) ]
64
64
pub ( crate ) type GlobalTrayIconEventListener < T > =
65
65
Box < dyn Fn ( & T , crate :: tray:: TrayIconEvent ) + Send + Sync > ;
66
- pub ( crate ) type GlobalWindowEventListener < R > = Box < dyn Fn ( GlobalWindowEvent < R > ) + Send + Sync > ;
66
+ pub ( crate ) type GlobalWindowEventListener < R > = Box < dyn Fn ( & Window < R > , & WindowEvent ) + Send + Sync > ;
67
67
/// A closure that is run when the Tauri application is setting up.
68
68
pub type SetupHook < R > =
69
69
Box < dyn FnOnce ( & mut App < R > ) -> Result < ( ) , Box < dyn std:: error:: Error > > + Send > ;
@@ -219,26 +219,6 @@ impl From<EventLoopMessage> for RunEvent {
219
219
}
220
220
}
221
221
222
- /// A window event that was triggered on the specified window.
223
- #[ default_runtime( crate :: Wry , wry) ]
224
- #[ derive( Debug ) ]
225
- pub struct GlobalWindowEvent < R : Runtime > {
226
- pub ( crate ) event : WindowEvent ,
227
- pub ( crate ) window : Window < R > ,
228
- }
229
-
230
- impl < R : Runtime > GlobalWindowEvent < R > {
231
- /// The event payload.
232
- pub fn event ( & self ) -> & WindowEvent {
233
- & self . event
234
- }
235
-
236
- /// The window that the event belongs to.
237
- pub fn window ( & self ) -> & Window < R > {
238
- & self . window
239
- }
240
- }
241
-
242
222
/// The asset resolver is a helper to access the [`tauri_utils::assets::Assets`] interface.
243
223
#[ derive( Debug , Clone ) ]
244
224
pub struct AssetResolver < R : Runtime > {
@@ -1304,18 +1284,18 @@ impl<R: Runtime> Builder<R> {
1304
1284
/// # Examples
1305
1285
/// ```
1306
1286
/// tauri::Builder::default()
1307
- /// .on_window_event(|event| match event.event() {
1287
+ /// .on_window_event(|window, event| match event {
1308
1288
/// tauri::WindowEvent::Focused(focused) => {
1309
1289
/// // hide window whenever it loses focus
1310
1290
/// if !focused {
1311
- /// event. window() .hide().unwrap();
1291
+ /// window.hide().unwrap();
1312
1292
/// }
1313
1293
/// }
1314
1294
/// _ => {}
1315
1295
/// });
1316
1296
/// ```
1317
1297
#[ must_use]
1318
- pub fn on_window_event < F : Fn ( GlobalWindowEvent < R > ) + Send + Sync + ' static > (
1298
+ pub fn on_window_event < F : Fn ( & Window < R > , & WindowEvent ) + Send + Sync + ' static > (
1319
1299
mut self ,
1320
1300
handler : F ,
1321
1301
) -> Self {
0 commit comments