Skip to main content

iced_core/window/
event.rs

1use crate::time::Instant;
2use crate::{Point, Size};
3
4use std::path::PathBuf;
5
6/// A window-related event.
7#[derive(PartialEq, Clone, Debug)]
8pub enum Event {
9    /// A window was opened.
10    Opened {
11        /// The position of the opened window. This is relative to the top-left corner of the desktop
12        /// the window is on, including virtual desktops. Refers to window's "outer" position,
13        /// or the window area, in logical pixels.
14        ///
15        /// **Note**: Not available in Wayland.
16        position: Option<Point>,
17        /// The size of the created window. This is its "inner" size, or the size of the
18        /// client area, in logical pixels.
19        size: Size,
20        /// The scale factor of the created window.
21        scale_factor: f32,
22    },
23
24    /// A window was closed.
25    Closed,
26
27    /// A window was moved.
28    Moved(Point),
29
30    /// A window was resized.
31    Resized(Size),
32
33    /// A window changed its scale factor.
34    Rescaled(f32),
35
36    /// A window redraw was requested.
37    ///
38    /// The [`Instant`] contains the current time.
39    RedrawRequested(Instant),
40
41    /// The user has requested for the window to close.
42    CloseRequested,
43
44    /// A window was focused.
45    Focused,
46
47    /// A window was unfocused.
48    Unfocused,
49
50    /// A file is being hovered over the window.
51    ///
52    /// When the user hovers multiple files at once, this event will be emitted
53    /// for each file separately.
54    ///
55    /// ## Platform-specific
56    ///
57    /// - **Wayland:** Not implemented.
58    FileHovered(PathBuf),
59
60    /// A file has been dropped into the window.
61    ///
62    /// When the user drops multiple files at once, this event will be emitted
63    /// for each file separately.
64    ///
65    /// ## Platform-specific
66    ///
67    /// - **Wayland:** Not implemented.
68    FileDropped(PathBuf),
69
70    /// A file was hovered, but has exited the window.
71    ///
72    /// There will be a single `FilesHoveredLeft` event triggered even if
73    /// multiple files were hovered.
74    ///
75    /// ## Platform-specific
76    ///
77    /// - **Wayland:** Not implemented.
78    FilesHoveredLeft,
79}