chore: remove platform WindowId's
WindowId is a window _identifier_, and as such doesn't store anything (unlike a _handle_). So we can safely make only be defined once, in the core crate. There are a few backends where we still use `into_raw` internally; I consider these patterns discouraged, we should not be passing around important state in the window id.
This commit is contained in:
parent
eccd9e415d
commit
da2268ae22
35 changed files with 226 additions and 379 deletions
|
|
@ -11,7 +11,7 @@ use crate::dpi::{PhysicalPosition, PhysicalSize, Position, Size};
|
|||
use crate::error::RequestError;
|
||||
pub use crate::icon::{BadIcon, Icon};
|
||||
use crate::monitor::{MonitorHandle, VideoModeHandle};
|
||||
use crate::platform_impl::{self, PlatformSpecificWindowAttributes};
|
||||
use crate::platform_impl::PlatformSpecificWindowAttributes;
|
||||
use crate::utils::AsAny;
|
||||
|
||||
/// Identifier of a window. Unique for each window.
|
||||
|
|
@ -21,21 +21,21 @@ use crate::utils::AsAny;
|
|||
/// Whenever you receive an event specific to a window, this event contains a `WindowId` which you
|
||||
/// can then compare to the ids of your windows.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct WindowId(pub(crate) platform_impl::WindowId);
|
||||
pub struct WindowId(usize);
|
||||
|
||||
impl WindowId {
|
||||
/// Convert the `WindowId` into the underlying integer.
|
||||
///
|
||||
/// This is useful if you need to pass the ID across an FFI boundary, or store it in an atomic.
|
||||
pub const fn into_raw(self) -> u64 {
|
||||
self.0.into_raw()
|
||||
pub const fn into_raw(self) -> usize {
|
||||
self.0
|
||||
}
|
||||
|
||||
/// Construct a `WindowId` from the underlying integer.
|
||||
///
|
||||
/// This should only be called with integers returned from [`WindowId::into_raw`].
|
||||
pub const fn from_raw(id: u64) -> Self {
|
||||
Self(platform_impl::WindowId::from_raw(id))
|
||||
pub const fn from_raw(id: usize) -> Self {
|
||||
Self(id)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue