Implement From<u64> for WindowId and vise-versa
This should help downstream applications to expose WindowId to the end users via e.g. IPC to control particular windows in multi window systems.
This commit is contained in:
parent
c55d97183d
commit
cb41c58f21
14 changed files with 115 additions and 60 deletions
|
|
@ -162,19 +162,23 @@ pub enum Window {
|
|||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub enum WindowId {
|
||||
#[cfg(feature = "x11")]
|
||||
X(x11::WindowId),
|
||||
#[cfg(feature = "wayland")]
|
||||
Wayland(wayland::WindowId),
|
||||
pub struct WindowId(u64);
|
||||
|
||||
impl From<WindowId> for u64 {
|
||||
fn from(window_id: WindowId) -> Self {
|
||||
window_id.0
|
||||
}
|
||||
}
|
||||
|
||||
impl From<u64> for WindowId {
|
||||
fn from(raw_id: u64) -> Self {
|
||||
Self(raw_id)
|
||||
}
|
||||
}
|
||||
|
||||
impl WindowId {
|
||||
pub const unsafe fn dummy() -> Self {
|
||||
#[cfg(feature = "wayland")]
|
||||
return WindowId::Wayland(wayland::WindowId::dummy());
|
||||
#[cfg(all(not(feature = "wayland"), feature = "x11"))]
|
||||
return WindowId::X(x11::WindowId::dummy());
|
||||
Self(0)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -314,7 +318,12 @@ impl Window {
|
|||
|
||||
#[inline]
|
||||
pub fn id(&self) -> WindowId {
|
||||
x11_or_wayland!(match self; Window(w) => w.id(); as WindowId)
|
||||
match self {
|
||||
#[cfg(feature = "wayland")]
|
||||
Self::Wayland(window) => window.id(),
|
||||
#[cfg(feature = "x11")]
|
||||
Self::X(window) => window.id(),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue