From 0ad53a3d5c7b5fb5785a64102ee1ad7df9a5fb2b Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 19 Sep 2022 20:59:37 -0300 Subject: add `window::Id` to `Event` and `Action` --- native/src/command/action.rs | 8 +++++--- native/src/event.rs | 2 +- native/src/window/id.rs | 3 +++ 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'native') diff --git a/native/src/command/action.rs b/native/src/command/action.rs index a6954f8f..924f95e6 100644 --- a/native/src/command/action.rs +++ b/native/src/command/action.rs @@ -20,7 +20,7 @@ pub enum Action { Clipboard(clipboard::Action), /// Run a window action. - Window(window::Action), + Window(window::Id, window::Action), /// Run a system action. System(system::Action), @@ -46,7 +46,7 @@ impl Action { match self { Self::Future(future) => Action::Future(Box::pin(future.map(f))), Self::Clipboard(action) => Action::Clipboard(action.map(f)), - Self::Window(window) => Action::Window(window.map(f)), + Self::Window(id, window) => Action::Window(id, window.map(f)), Self::System(system) => Action::System(system.map(f)), Self::Widget(widget) => Action::Widget(widget.map(f)), } @@ -60,7 +60,9 @@ impl fmt::Debug for Action { Self::Clipboard(action) => { write!(f, "Action::Clipboard({:?})", action) } - Self::Window(action) => write!(f, "Action::Window({:?})", action), + Self::Window(id, action) => { + write!(f, "Action::Window({:?}, {:?})", id, action) + } Self::System(action) => write!(f, "Action::System({:?})", action), Self::Widget(_action) => write!(f, "Action::Widget"), } diff --git a/native/src/event.rs b/native/src/event.rs index bcfaf891..eb826399 100644 --- a/native/src/event.rs +++ b/native/src/event.rs @@ -19,7 +19,7 @@ pub enum Event { Mouse(mouse::Event), /// A window event - Window(window::Event), + Window(window::Id, window::Event), /// A touch event Touch(touch::Event), diff --git a/native/src/window/id.rs b/native/src/window/id.rs index 059cf4e7..5060e162 100644 --- a/native/src/window/id.rs +++ b/native/src/window/id.rs @@ -6,6 +6,9 @@ use std::hash::{Hash, Hasher}; 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) pub fn new(id: impl Hash) -> Id { let mut hasher = DefaultHasher::new(); -- cgit