diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/src/window/event.rs | 32 | ||||
-rw-r--r-- | core/src/window/id.rs | 14 |
2 files changed, 23 insertions, 23 deletions
diff --git a/core/src/window/event.rs b/core/src/window/event.rs index 3ab7cd81..b9ee7aca 100644 --- a/core/src/window/event.rs +++ b/core/src/window/event.rs @@ -6,6 +6,22 @@ use std::path::PathBuf; /// A window-related event. #[derive(PartialEq, Clone, Debug)] pub enum Event { + /// A window was opened. + Opened { + /// The position of the opened window. This is relative to the top-left corner of the desktop + /// the window is on, including virtual desktops. Refers to window's "inner" position, + /// or the client area, in logical pixels. + /// + /// **Note**: Not available in Wayland. + position: Option<Point>, + /// The size of the created window. This is its "inner" size, or the size of the + /// client area, in logical pixels. + size: Size, + }, + + /// A window was closed. + Closed, + /// A window was moved. Moved { /// The new logical x location of the window @@ -30,22 +46,6 @@ pub enum Event { /// The user has requested for the window to close. CloseRequested, - /// A window was created. - Created { - /// The position of the created window. This is relative to the top-left corner of the desktop - /// the window is on, including virtual desktops. Refers to window's "inner" position, - /// or the client area, in logical pixels. - /// - /// **Note**: Not available in Wayland. - position: Option<Point>, - /// The size of the created window. This is its "inner" size, or the size of the - /// client area, in logical pixels. - size: Size, - }, - - /// A window was destroyed by the runtime. - Destroyed, - /// A window was focused. Focused, diff --git a/core/src/window/id.rs b/core/src/window/id.rs index 65002d43..20474c8f 100644 --- a/core/src/window/id.rs +++ b/core/src/window/id.rs @@ -1,5 +1,6 @@ -use std::collections::hash_map::DefaultHasher; -use std::hash::{Hash, Hasher}; +use std::hash::Hash; + +use std::sync::atomic::{self, AtomicU64}; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] /// The id of the window. @@ -7,15 +8,14 @@ use std::hash::{Hash, Hasher}; /// Internally Iced reserves `window::Id::MAIN` for the first window spawned. pub struct Id(u64); +static COUNT: AtomicU64 = AtomicU64::new(1); + impl Id { /// The reserved window [`Id`] for the first window in an Iced application. pub const MAIN: Self = Id(0); /// Creates a new unique window [`Id`]. - pub fn new(id: impl Hash) -> Id { - let mut hasher = DefaultHasher::new(); - id.hash(&mut hasher); - - Id(hasher.finish()) + pub fn unique() -> Id { + Id(COUNT.fetch_add(1, atomic::Ordering::Relaxed)) } } |