Skip to main content

bevy_window/
event.rs

1use alloc::string::String;
2#[cfg(feature = "bevy_reflect")]
3use bevy_ecs::prelude::ReflectMessage;
4use bevy_ecs::{entity::Entity, message::Message};
5use bevy_input::{
6    gestures::*,
7    keyboard::{KeyboardFocusLost, KeyboardInput},
8    mouse::{MouseButtonInput, MouseMotion, MouseWheel},
9    touch::TouchInput,
10};
11use bevy_math::{IVec2, Vec2};
12
13#[cfg(feature = "std")]
14use std::path::PathBuf;
15
16#[cfg(not(feature = "std"))]
17use alloc::string::String as PathBuf;
18
19#[cfg(feature = "bevy_reflect")]
20use bevy_reflect::Reflect;
21
22#[cfg(feature = "serialize")]
23use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
24
25use crate::WindowTheme;
26
27/// A window event that is sent whenever a window's logical size has changed.
28#[derive(Message, Debug, Clone, PartialEq)]
29#[cfg_attr(
30    feature = "bevy_reflect",
31    derive(Reflect),
32    reflect(Debug, PartialEq, Clone, Message)
33)]
34#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
35#[cfg_attr(
36    all(feature = "serialize", feature = "bevy_reflect"),
37    reflect(Serialize, Deserialize)
38)]
39pub struct WindowResized {
40    /// Window that has changed.
41    pub window: Entity,
42    /// The new logical width of the window.
43    pub width: f32,
44    /// The new logical height of the window.
45    pub height: f32,
46}
47
48/// An event that indicates all of the application's windows should be redrawn,
49/// even if their control flow is set to `Wait` and there have been no window events.
50#[derive(Message, Debug, Clone, PartialEq, Eq)]
51#[cfg_attr(
52    feature = "bevy_reflect",
53    derive(Reflect),
54    reflect(Debug, PartialEq, Clone, Message)
55)]
56#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
57#[cfg_attr(
58    all(feature = "serialize", feature = "bevy_reflect"),
59    reflect(Serialize, Deserialize)
60)]
61pub struct RequestRedraw;
62
63/// An event that is sent whenever a new window is created.
64///
65/// To create a new window, spawn an entity with a [`Window`](`crate::Window`) on it.
66#[derive(Message, Debug, Clone, PartialEq, Eq)]
67#[cfg_attr(
68    feature = "bevy_reflect",
69    derive(Reflect),
70    reflect(Debug, PartialEq, Clone, Message)
71)]
72#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
73#[cfg_attr(
74    all(feature = "serialize", feature = "bevy_reflect"),
75    reflect(Serialize, Deserialize)
76)]
77pub struct WindowCreated {
78    /// Window that has been created.
79    pub window: Entity,
80}
81
82/// An event that is sent whenever the operating systems requests that a window
83/// be closed. This will be sent when the close button of the window is pressed.
84///
85/// If the default [`WindowPlugin`] is used, these events are handled
86/// by closing the corresponding [`Window`].
87/// To disable this behavior, set `close_when_requested` on the [`WindowPlugin`]
88/// to `false`.
89///
90/// [`WindowPlugin`]: crate::WindowPlugin
91/// [`Window`]: crate::Window
92#[derive(Message, Debug, Clone, PartialEq, Eq)]
93#[cfg_attr(
94    feature = "bevy_reflect",
95    derive(Reflect),
96    reflect(Debug, PartialEq, Clone, Message)
97)]
98#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
99#[cfg_attr(
100    all(feature = "serialize", feature = "bevy_reflect"),
101    reflect(Serialize, Deserialize)
102)]
103pub struct WindowCloseRequested {
104    /// Window to close.
105    pub window: Entity,
106}
107
108/// An event that is sent whenever a window is closed. This will be sent when
109/// the window entity loses its [`Window`](crate::window::Window) component or is despawned.
110#[derive(Message, Debug, Clone, PartialEq, Eq)]
111#[cfg_attr(
112    feature = "bevy_reflect",
113    derive(Reflect),
114    reflect(Debug, PartialEq, Clone)
115)]
116#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
117#[cfg_attr(
118    all(feature = "serialize", feature = "bevy_reflect"),
119    reflect(Serialize, Deserialize)
120)]
121pub struct WindowClosed {
122    /// Window that has been closed.
123    ///
124    /// Note that this entity probably no longer exists
125    /// by the time this event is received.
126    pub window: Entity,
127}
128
129/// An event that is sent whenever a window is closing. This will be sent when
130/// after a [`WindowCloseRequested`] event is received and the window is in the process of closing.
131#[derive(Message, Debug, Clone, PartialEq, Eq)]
132#[cfg_attr(
133    feature = "bevy_reflect",
134    derive(Reflect),
135    reflect(Debug, PartialEq, Clone)
136)]
137#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
138#[cfg_attr(
139    all(feature = "serialize", feature = "bevy_reflect"),
140    reflect(Serialize, Deserialize)
141)]
142pub struct WindowClosing {
143    /// Window that has been requested to close and is the process of closing.
144    pub window: Entity,
145}
146
147/// An event that is sent whenever a window is destroyed by the underlying window system.
148///
149/// Note that if your application only has a single window, this event may be your last chance to
150/// persist state before the application terminates.
151#[derive(Message, Debug, Clone, PartialEq, Eq)]
152#[cfg_attr(
153    feature = "bevy_reflect",
154    derive(Reflect),
155    reflect(Debug, PartialEq, Clone, Message)
156)]
157#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
158#[cfg_attr(
159    all(feature = "serialize", feature = "bevy_reflect"),
160    reflect(Serialize, Deserialize)
161)]
162pub struct WindowDestroyed {
163    /// Window that has been destroyed.
164    ///
165    /// Note that this entity probably no longer exists
166    /// by the time this event is received.
167    pub window: Entity,
168}
169
170/// An event reporting that the mouse cursor has moved inside a window.
171///
172/// The event is sent only if the cursor is over one of the application's windows.
173/// It is the translated version of [`WindowEvent::CursorMoved`] from the `winit` crate with the addition of `delta`.
174///
175/// Not to be confused with the `MouseMotion` event from `bevy_input`.
176///
177/// Because the range of data is limited by the window area and it may have been transformed by the OS to implement certain effects like acceleration,
178/// you should not use it for non-cursor-like behavior such as 3D camera control. Please see `MouseMotion` instead.
179///
180/// [`WindowEvent::CursorMoved`]: https://docs.rs/winit/latest/winit/event/enum.WindowEvent.html#variant.CursorMoved
181#[derive(Message, Debug, Clone, PartialEq)]
182#[cfg_attr(
183    feature = "bevy_reflect",
184    derive(Reflect),
185    reflect(Debug, PartialEq, Clone, Message)
186)]
187#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
188#[cfg_attr(
189    all(feature = "serialize", feature = "bevy_reflect"),
190    reflect(Serialize, Deserialize)
191)]
192pub struct CursorMoved {
193    /// Window that the cursor moved inside.
194    pub window: Entity,
195    /// The cursor position in logical pixels.
196    pub position: Vec2,
197    /// The change in the position of the cursor since the last event was sent.
198    /// This value is `None` if the cursor was outside the window area during the last frame.
199    // Because the range of this data is limited by the display area and it may have been
200    //  transformed by the OS to implement effects such as cursor acceleration, it should
201    // not be used to implement non-cursor-like interactions such as 3D camera control.
202    pub delta: Option<Vec2>,
203}
204
205/// An event that is sent whenever the user's cursor enters a window.
206#[derive(Message, Debug, Clone, PartialEq, Eq)]
207#[cfg_attr(
208    feature = "bevy_reflect",
209    derive(Reflect),
210    reflect(Debug, PartialEq, Clone, Message)
211)]
212#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
213#[cfg_attr(
214    all(feature = "serialize", feature = "bevy_reflect"),
215    reflect(Serialize, Deserialize)
216)]
217pub struct CursorEntered {
218    /// Window that the cursor entered.
219    pub window: Entity,
220}
221
222/// An event that is sent whenever the user's cursor leaves a window.
223#[derive(Message, Debug, Clone, PartialEq, Eq)]
224#[cfg_attr(
225    feature = "bevy_reflect",
226    derive(Reflect),
227    reflect(Debug, PartialEq, Clone, Message)
228)]
229#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
230#[cfg_attr(
231    all(feature = "serialize", feature = "bevy_reflect"),
232    reflect(Serialize, Deserialize)
233)]
234pub struct CursorLeft {
235    /// Window that the cursor left.
236    pub window: Entity,
237}
238
239/// An Input Method Editor event.
240///
241/// This event is the translated version of the `WindowEvent::Ime` from the `winit` crate.
242///
243/// It is only sent if IME was enabled on the window with [`Window::ime_enabled`](crate::window::Window::ime_enabled).
244#[derive(Message, Debug, Clone, PartialEq, Eq)]
245#[cfg_attr(
246    feature = "bevy_reflect",
247    derive(Reflect),
248    reflect(Debug, PartialEq, Clone, Message)
249)]
250#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
251#[cfg_attr(
252    all(feature = "serialize", feature = "bevy_reflect"),
253    reflect(Serialize, Deserialize)
254)]
255pub enum Ime {
256    /// Notifies when a new composing text should be set at the cursor position.
257    Preedit {
258        /// Window that received the event.
259        window: Entity,
260        /// Current value.
261        value: String,
262        /// Cursor begin and end position.
263        ///
264        /// `None` indicated the cursor should be hidden
265        cursor: Option<(usize, usize)>,
266    },
267    /// Notifies when text should be inserted into the editor widget.
268    Commit {
269        /// Window that received the event.
270        window: Entity,
271        /// Input string
272        value: String,
273    },
274    /// Notifies when the IME was enabled.
275    ///
276    /// After this event, you will receive events `Ime::Preedit` and `Ime::Commit`.
277    Enabled {
278        /// Window that received the event.
279        window: Entity,
280    },
281    /// Notifies when the IME was disabled.
282    Disabled {
283        /// Window that received the event.
284        window: Entity,
285    },
286}
287
288/// An event that indicates a window has received or lost focus.
289#[derive(Message, Debug, Clone, PartialEq, Eq)]
290#[cfg_attr(
291    feature = "bevy_reflect",
292    derive(Reflect),
293    reflect(Debug, PartialEq, Clone, Message)
294)]
295#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
296#[cfg_attr(
297    all(feature = "serialize", feature = "bevy_reflect"),
298    reflect(Serialize, Deserialize)
299)]
300pub struct WindowFocused {
301    /// Window that changed focus.
302    pub window: Entity,
303    /// Whether it was focused (true) or lost focused (false).
304    pub focused: bool,
305}
306
307/// The window has been occluded (completely hidden from view).
308///
309/// This is different to window visibility as it depends on
310/// whether the window is closed, minimized, set invisible,
311/// or fully occluded by another window.
312///
313/// It is the translated version of [`WindowEvent::Occluded`] from the `winit` crate.
314///
315/// [`WindowEvent::Occluded`]: https://docs.rs/winit/latest/winit/event/enum.WindowEvent.html#variant.Occluded
316#[derive(Message, Debug, Clone, PartialEq, Eq)]
317#[cfg_attr(
318    feature = "bevy_reflect",
319    derive(Reflect),
320    reflect(Debug, PartialEq, Clone, Message)
321)]
322#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
323#[cfg_attr(
324    all(feature = "serialize", feature = "bevy_reflect"),
325    reflect(Serialize, Deserialize)
326)]
327pub struct WindowOccluded {
328    /// Window that changed occluded state.
329    pub window: Entity,
330    /// Whether it was occluded (true) or not occluded (false).
331    pub occluded: bool,
332}
333
334/// An event that indicates a window's scale factor has changed.
335#[derive(Message, Debug, Clone, PartialEq)]
336#[cfg_attr(
337    feature = "bevy_reflect",
338    derive(Reflect),
339    reflect(Debug, PartialEq, Clone, Message)
340)]
341#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
342#[cfg_attr(
343    all(feature = "serialize", feature = "bevy_reflect"),
344    reflect(Serialize, Deserialize)
345)]
346pub struct WindowScaleFactorChanged {
347    /// Window that had its scale factor changed.
348    pub window: Entity,
349    /// The new scale factor.
350    pub scale_factor: f64,
351}
352
353/// An event that indicates a window's OS-reported scale factor has changed.
354#[derive(Message, Debug, Clone, PartialEq)]
355#[cfg_attr(
356    feature = "bevy_reflect",
357    derive(Reflect),
358    reflect(Debug, PartialEq, Clone, Message)
359)]
360#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
361#[cfg_attr(
362    all(feature = "serialize", feature = "bevy_reflect"),
363    reflect(Serialize, Deserialize)
364)]
365pub struct WindowBackendScaleFactorChanged {
366    /// Window that had its scale factor changed by the backend.
367    pub window: Entity,
368    /// The new scale factor.
369    pub scale_factor: f64,
370}
371
372/// Events related to files being dragged and dropped on a window.
373#[derive(Message, Debug, Clone, PartialEq, Eq)]
374#[cfg_attr(
375    feature = "bevy_reflect",
376    derive(Reflect),
377    reflect(Debug, PartialEq, Clone, Message)
378)]
379#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
380#[cfg_attr(
381    all(feature = "serialize", feature = "bevy_reflect"),
382    reflect(Serialize, Deserialize)
383)]
384pub enum FileDragAndDrop {
385    /// File is being dropped into a window.
386    DroppedFile {
387        /// Window the file was dropped into.
388        window: Entity,
389        /// Path to the file that was dropped in.
390        path_buf: PathBuf,
391    },
392
393    /// File is currently being hovered over a window.
394    HoveredFile {
395        /// Window a file is possibly going to be dropped into.
396        window: Entity,
397        /// Path to the file that might be dropped in.
398        path_buf: PathBuf,
399    },
400
401    /// File hovering was canceled.
402    HoveredFileCanceled {
403        /// Window that had a canceled file drop.
404        window: Entity,
405    },
406}
407
408/// An event that is sent when a window is repositioned in physical pixels.
409#[derive(Message, Debug, Clone, PartialEq, Eq)]
410#[cfg_attr(
411    feature = "bevy_reflect",
412    derive(Reflect),
413    reflect(Debug, PartialEq, Clone, Message)
414)]
415#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
416#[cfg_attr(
417    all(feature = "serialize", feature = "bevy_reflect"),
418    reflect(Serialize, Deserialize)
419)]
420pub struct WindowMoved {
421    /// Window that moved.
422    pub window: Entity,
423    /// Where the window moved to in physical pixels.
424    pub position: IVec2,
425}
426
427/// An event sent when the system theme changes for a window.
428///
429/// This event is only sent when the window is relying on the system theme to control its appearance.
430/// i.e. It is only sent when [`Window::window_theme`](crate::window::Window::window_theme) is `None` and the system theme changes.
431#[derive(Message, Debug, Clone, PartialEq, Eq)]
432#[cfg_attr(
433    feature = "bevy_reflect",
434    derive(Reflect),
435    reflect(Debug, PartialEq, Clone, Message)
436)]
437#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
438#[cfg_attr(
439    all(feature = "serialize", feature = "bevy_reflect"),
440    reflect(Serialize, Deserialize)
441)]
442pub struct WindowThemeChanged {
443    /// Window for which the system theme has changed.
444    pub window: Entity,
445    /// The new system theme.
446    pub theme: WindowTheme,
447}
448
449/// Application lifetime events
450#[derive(Message, Debug, Clone, Copy, PartialEq, Eq)]
451#[cfg_attr(
452    feature = "bevy_reflect",
453    derive(Reflect),
454    reflect(Debug, PartialEq, Clone, Message)
455)]
456#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
457#[cfg_attr(
458    all(feature = "serialize", feature = "bevy_reflect"),
459    reflect(Serialize, Deserialize)
460)]
461pub enum AppLifecycle {
462    /// The application is not started yet.
463    Idle,
464    /// The application is running.
465    Running,
466    /// The application is going to be suspended.
467    /// Applications have one frame to react to this event before being paused in the background.
468    WillSuspend,
469    /// The application was suspended.
470    Suspended,
471    /// The application is going to be resumed.
472    /// Applications have one extra frame to react to this event before being fully resumed.
473    WillResume,
474}
475
476impl AppLifecycle {
477    /// Return `true` if the app can be updated.
478    #[inline]
479    pub fn is_active(&self) -> bool {
480        match self {
481            Self::Idle | Self::Suspended => false,
482            Self::Running | Self::WillSuspend | Self::WillResume => true,
483        }
484    }
485}
486
487/// Wraps all `bevy_window` and `bevy_input` events in a common enum.
488///
489/// Read these events with `MessageReader<WindowEvent>` if you need to
490/// access window events in the order they were received from the
491/// operating system. Otherwise, the event types are individually
492/// readable with `MessageReader<E>` (e.g. `MessageReader<KeyboardInput>`).
493#[derive(Message, Debug, Clone, PartialEq)]
494#[cfg_attr(
495    feature = "bevy_reflect",
496    derive(Reflect),
497    reflect(Debug, PartialEq, Clone, Message)
498)]
499#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
500#[cfg_attr(
501    all(feature = "serialize", feature = "bevy_reflect"),
502    reflect(Serialize, Deserialize)
503)]
504pub enum WindowEvent {
505    /// An application lifecycle event.
506    AppLifecycle(AppLifecycle),
507    /// The user's cursor has entered a window.
508    CursorEntered(CursorEntered),
509    ///The user's cursor has left a window.
510    CursorLeft(CursorLeft),
511    /// The user's cursor has moved inside a window.
512    CursorMoved(CursorMoved),
513    /// A file drag and drop event.
514    FileDragAndDrop(FileDragAndDrop),
515    /// An Input Method Editor event.
516    Ime(Ime),
517    /// A redraw of all of the application's windows has been requested.
518    RequestRedraw(RequestRedraw),
519    /// The window's OS-reported scale factor has changed.
520    WindowBackendScaleFactorChanged(WindowBackendScaleFactorChanged),
521    /// The OS has requested that a window be closed.
522    WindowCloseRequested(WindowCloseRequested),
523    /// A new window has been created.
524    WindowCreated(WindowCreated),
525    /// A window has been destroyed by the underlying windowing system.
526    WindowDestroyed(WindowDestroyed),
527    /// A window has received or lost focus.
528    WindowFocused(WindowFocused),
529    /// A window has been moved.
530    WindowMoved(WindowMoved),
531    /// A window has started or stopped being occluded.
532    WindowOccluded(WindowOccluded),
533    /// A window's logical size has changed.
534    WindowResized(WindowResized),
535    /// A window's scale factor has changed.
536    WindowScaleFactorChanged(WindowScaleFactorChanged),
537    /// Sent for windows that are using the system theme when the system theme changes.
538    WindowThemeChanged(WindowThemeChanged),
539
540    /// The state of a mouse button has changed.
541    MouseButtonInput(MouseButtonInput),
542    /// The physical position of a pointing device has changed.
543    MouseMotion(MouseMotion),
544    /// The mouse wheel has moved.
545    MouseWheel(MouseWheel),
546
547    /// A two finger pinch gesture.
548    PinchGesture(PinchGesture),
549    /// A two finger rotation gesture.
550    RotationGesture(RotationGesture),
551    /// A double tap gesture.
552    DoubleTapGesture(DoubleTapGesture),
553    /// A pan gesture.
554    PanGesture(PanGesture),
555
556    /// A touch input state change.
557    TouchInput(TouchInput),
558
559    /// A keyboard input.
560    KeyboardInput(KeyboardInput),
561    /// Sent when focus has been lost for all Bevy windows.
562    ///
563    /// Used to clear pressed key state.
564    KeyboardFocusLost(KeyboardFocusLost),
565}
566
567impl From<AppLifecycle> for WindowEvent {
568    fn from(e: AppLifecycle) -> Self {
569        Self::AppLifecycle(e)
570    }
571}
572
573impl From<CursorEntered> for WindowEvent {
574    fn from(e: CursorEntered) -> Self {
575        Self::CursorEntered(e)
576    }
577}
578
579impl From<CursorLeft> for WindowEvent {
580    fn from(e: CursorLeft) -> Self {
581        Self::CursorLeft(e)
582    }
583}
584
585impl From<CursorMoved> for WindowEvent {
586    fn from(e: CursorMoved) -> Self {
587        Self::CursorMoved(e)
588    }
589}
590
591impl From<FileDragAndDrop> for WindowEvent {
592    fn from(e: FileDragAndDrop) -> Self {
593        Self::FileDragAndDrop(e)
594    }
595}
596
597impl From<Ime> for WindowEvent {
598    fn from(e: Ime) -> Self {
599        Self::Ime(e)
600    }
601}
602
603impl From<RequestRedraw> for WindowEvent {
604    fn from(e: RequestRedraw) -> Self {
605        Self::RequestRedraw(e)
606    }
607}
608
609impl From<WindowBackendScaleFactorChanged> for WindowEvent {
610    fn from(e: WindowBackendScaleFactorChanged) -> Self {
611        Self::WindowBackendScaleFactorChanged(e)
612    }
613}
614
615impl From<WindowCloseRequested> for WindowEvent {
616    fn from(e: WindowCloseRequested) -> Self {
617        Self::WindowCloseRequested(e)
618    }
619}
620
621impl From<WindowCreated> for WindowEvent {
622    fn from(e: WindowCreated) -> Self {
623        Self::WindowCreated(e)
624    }
625}
626
627impl From<WindowDestroyed> for WindowEvent {
628    fn from(e: WindowDestroyed) -> Self {
629        Self::WindowDestroyed(e)
630    }
631}
632
633impl From<WindowFocused> for WindowEvent {
634    fn from(e: WindowFocused) -> Self {
635        Self::WindowFocused(e)
636    }
637}
638
639impl From<WindowMoved> for WindowEvent {
640    fn from(e: WindowMoved) -> Self {
641        Self::WindowMoved(e)
642    }
643}
644
645impl From<WindowOccluded> for WindowEvent {
646    fn from(e: WindowOccluded) -> Self {
647        Self::WindowOccluded(e)
648    }
649}
650
651impl From<WindowResized> for WindowEvent {
652    fn from(e: WindowResized) -> Self {
653        Self::WindowResized(e)
654    }
655}
656
657impl From<WindowScaleFactorChanged> for WindowEvent {
658    fn from(e: WindowScaleFactorChanged) -> Self {
659        Self::WindowScaleFactorChanged(e)
660    }
661}
662
663impl From<WindowThemeChanged> for WindowEvent {
664    fn from(e: WindowThemeChanged) -> Self {
665        Self::WindowThemeChanged(e)
666    }
667}
668
669impl From<MouseButtonInput> for WindowEvent {
670    fn from(e: MouseButtonInput) -> Self {
671        Self::MouseButtonInput(e)
672    }
673}
674
675impl From<MouseMotion> for WindowEvent {
676    fn from(e: MouseMotion) -> Self {
677        Self::MouseMotion(e)
678    }
679}
680
681impl From<MouseWheel> for WindowEvent {
682    fn from(e: MouseWheel) -> Self {
683        Self::MouseWheel(e)
684    }
685}
686
687impl From<PinchGesture> for WindowEvent {
688    fn from(e: PinchGesture) -> Self {
689        Self::PinchGesture(e)
690    }
691}
692
693impl From<RotationGesture> for WindowEvent {
694    fn from(e: RotationGesture) -> Self {
695        Self::RotationGesture(e)
696    }
697}
698
699impl From<DoubleTapGesture> for WindowEvent {
700    fn from(e: DoubleTapGesture) -> Self {
701        Self::DoubleTapGesture(e)
702    }
703}
704
705impl From<PanGesture> for WindowEvent {
706    fn from(e: PanGesture) -> Self {
707        Self::PanGesture(e)
708    }
709}
710
711impl From<TouchInput> for WindowEvent {
712    fn from(e: TouchInput) -> Self {
713        Self::TouchInput(e)
714    }
715}
716
717impl From<KeyboardInput> for WindowEvent {
718    fn from(e: KeyboardInput) -> Self {
719        Self::KeyboardInput(e)
720    }
721}
722
723impl From<KeyboardFocusLost> for WindowEvent {
724    fn from(e: KeyboardFocusLost) -> Self {
725        Self::KeyboardFocusLost(e)
726    }
727}