surface: Introduce WeakCosmicSurface
This commit is contained in:
parent
9ad5c916f3
commit
615789cb14
1 changed files with 20 additions and 1 deletions
|
|
@ -22,7 +22,7 @@ use smithay::{
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
desktop::{
|
desktop::{
|
||||||
PopupManager, Window, WindowSurface, WindowSurfaceType, space::SpaceElement,
|
PopupManager, WeakWindow, Window, WindowSurface, WindowSurfaceType, space::SpaceElement,
|
||||||
utils::OutputPresentationFeedback,
|
utils::OutputPresentationFeedback,
|
||||||
},
|
},
|
||||||
input::{
|
input::{
|
||||||
|
|
@ -67,6 +67,9 @@ use crate::{
|
||||||
#[derive(Debug, Clone, PartialEq, Hash, Eq)]
|
#[derive(Debug, Clone, PartialEq, Hash, Eq)]
|
||||||
pub struct CosmicSurface(pub Window);
|
pub struct CosmicSurface(pub Window);
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct WeakCosmicSurface(pub WeakWindow);
|
||||||
|
|
||||||
impl From<ToplevelSurface> for CosmicSurface {
|
impl From<ToplevelSurface> for CosmicSurface {
|
||||||
fn from(s: ToplevelSurface) -> Self {
|
fn from(s: ToplevelSurface) -> Self {
|
||||||
CosmicSurface(Window::new_wayland_window(s))
|
CosmicSurface(Window::new_wayland_window(s))
|
||||||
|
|
@ -103,6 +106,12 @@ impl PartialEq<X11Surface> for CosmicSurface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PartialEq<WeakCosmicSurface> for CosmicSurface {
|
||||||
|
fn eq(&self, other: &WeakCosmicSurface) -> bool {
|
||||||
|
other.upgrade().is_some_and(|other| other == *self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct Minimized(AtomicBool);
|
struct Minimized(AtomicBool);
|
||||||
|
|
||||||
|
|
@ -849,6 +858,16 @@ impl CosmicSurface {
|
||||||
pub fn x11_surface(&self) -> Option<&X11Surface> {
|
pub fn x11_surface(&self) -> Option<&X11Surface> {
|
||||||
self.0.x11_surface()
|
self.0.x11_surface()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn downgrade(&self) -> WeakCosmicSurface {
|
||||||
|
WeakCosmicSurface(self.0.downgrade())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WeakCosmicSurface {
|
||||||
|
pub fn upgrade(&self) -> Option<CosmicSurface> {
|
||||||
|
self.0.upgrade().map(CosmicSurface)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IsAlive for CosmicSurface {
|
impl IsAlive for CosmicSurface {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue