1
0
Fork 0
forked from wry/wry

autocommit 2022-01-09 14:36:34 CET

This commit is contained in:
Julian Orth 2022-01-09 14:36:34 +01:00
parent 02d1c90501
commit 928f94daa6
14 changed files with 200 additions and 102 deletions

View file

@ -247,7 +247,7 @@ impl Clients {
dispatch_frame_requests: AsyncQueue::new(),
});
let display = Rc::new(WlDisplay::new(&data));
*data.objects.display.borrow_mut() = Some(display.clone());
data.objects.display.set(Some(display.clone()));
data.objects.add_client_object(display).expect("");
let client = ClientHolder {
_handler: global.eng.spawn(tasks::client(data.clone(), recv)),
@ -365,7 +365,7 @@ impl Client {
}
pub fn display(&self) -> Result<Rc<WlDisplay>, ClientError> {
match self.objects.display.borrow_mut().clone() {
match self.objects.display.get() {
Some(d) => Ok(d),
_ => Err(ClientError::NotADisplay(WL_DISPLAY_ID)),
}

View file

@ -13,9 +13,10 @@ use ahash::AHashMap;
use std::cell::{RefCell, RefMut};
use std::mem;
use std::rc::Rc;
use crate::utils::clonecell::CloneCell;
pub struct Objects {
pub display: RefCell<Option<Rc<WlDisplay>>>,
pub display: CloneCell<Option<Rc<WlDisplay>>>,
registry: CopyHashMap<ObjectId, Rc<dyn Object>>,
registries: CopyHashMap<WlRegistryId, Rc<WlRegistry>>,
pub surfaces: CopyHashMap<WlSurfaceId, Rc<WlSurface>>,
@ -33,7 +34,7 @@ const SEG_SIZE: usize = 8 * mem::size_of::<usize>();
impl Objects {
pub fn new() -> Self {
Self {
display: RefCell::new(None),
display: CloneCell::new(None),
registry: Default::default(),
registries: Default::default(),
surfaces: Default::default(),
@ -54,7 +55,7 @@ impl Objects {
}
registry.clear();
}
*self.display.borrow_mut() = None;
self.display.set(None);
self.regions.clear();
self.registries.clear();
self.surfaces.clear();