Add WindowId type

This commit is contained in:
Pierre Krieger 2017-02-03 09:13:11 +01:00
parent 9cd0430ec7
commit b988c174fe
4 changed files with 20 additions and 6 deletions

View file

@ -31,7 +31,7 @@ macro_rules! gen_api_transition {
for window in windows.iter() {
for event in window.poll_events() {
callback(::Event::WindowEvent {
window_id: &**window as *const Window as usize,
window_id: ::WindowId(WindowId(&**window as *const Window as usize)),
event: event,
})
}
@ -54,6 +54,9 @@ macro_rules! gen_api_transition {
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct WindowId(usize);
pub struct Window2 {
pub window: ::std::sync::Arc<Window>,
events_loop: ::std::sync::Weak<EventsLoop>,
@ -81,8 +84,8 @@ macro_rules! gen_api_transition {
}
#[inline]
pub fn id(&self) -> usize {
&*self.window as *const Window as usize
pub fn id(&self) -> WindowId {
WindowId(&*self.window as *const Window as usize)
}
}