summaryrefslogtreecommitdiffstats
path: root/native/src/window/id.rs
diff options
context:
space:
mode:
authorLibravatar bungoboingo <shankern@protonmail.com>2023-01-05 15:26:28 -0800
committerLibravatar bungoboingo <shankern@protonmail.com>2023-01-09 11:28:07 -0800
commitec41918ec40bddaba81235372f1566da59fd09f2 (patch)
treefb530943ccf14dfec3820bf65f71a9572fd3d8be /native/src/window/id.rs
parent1944e98f82b7efd5b268e04ba5ced065e55a218e (diff)
downloadiced-ec41918ec40bddaba81235372f1566da59fd09f2.tar.gz
iced-ec41918ec40bddaba81235372f1566da59fd09f2.tar.bz2
iced-ec41918ec40bddaba81235372f1566da59fd09f2.zip
Implemented window title update functionality for multiwindow.
Diffstat (limited to 'native/src/window/id.rs')
-rw-r--r--native/src/window/id.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/native/src/window/id.rs b/native/src/window/id.rs
index 5060e162..fa9761f5 100644
--- a/native/src/window/id.rs
+++ b/native/src/window/id.rs
@@ -1,15 +1,18 @@
use std::collections::hash_map::DefaultHasher;
+use std::fmt::{Display, Formatter};
use std::hash::{Hash, Hasher};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
-/// TODO(derezzedex)
+/// The ID of the window.
+///
+/// This is not necessarily the same as the window ID fetched from `winit::window::Window`.
pub struct Id(u64);
impl Id {
/// TODO(derezzedex): maybe change `u64` to an enum `Type::{Single, Multi(u64)}`
pub const MAIN: Self = Id(0);
- /// TODO(derezzedex)
+ /// Creates a new unique window ID.
pub fn new(id: impl Hash) -> Id {
let mut hasher = DefaultHasher::new();
id.hash(&mut hasher);
@@ -17,3 +20,9 @@ impl Id {
Id(hasher.finish())
}
}
+
+impl Display for Id {
+ fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+ write!(f, "Id({})", self.0)
+ }
+}