use crate::platform_impl::PlatformWindowId;
#[derive(Clone, Debug, Copy, PartialEq, Eq)]
pub struct WindowId(pub(crate) PlatformWindowId);
unsafe impl Send for WindowId {}
unsafe impl Sync for WindowId {}
impl WindowId {
pub const fn new(id: PlatformWindowId) -> Self {
Self(id)
}
pub fn platform_window_id(&self) -> &PlatformWindowId {
&self.0
}
pub const fn into_platform_window_id(self) -> PlatformWindowId {
self.0
}
pub fn as_u32(&self) -> u32 {
#[cfg(target_os = "macos")]
{
self.0
}
#[cfg(target_os = "windows")]
{
self.0.0 as _
}
}
}
impl From<u32> for WindowId {
fn from(id: u32) -> Self {
#[cfg(target_os = "macos")]
{
Self(id)
}
#[cfg(target_os = "windows")]
{
Self(windows::Win32::Foundation::HWND(id as _))
}
}
}
impl std::hash::Hash for WindowId {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.as_u32().hash(state);
}
}