portal: send toplevel identifier in jay_toplevel
This commit is contained in:
parent
8d6aaf79a7
commit
d4c0fb29ba
7 changed files with 92 additions and 15 deletions
|
|
@ -5,7 +5,7 @@ use {
|
|||
wire::{jay_toplevel::*, JayToplevelId},
|
||||
wl_usr::{usr_object::UsrObject, UsrCon},
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
std::{cell::RefCell, convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrJayToplevel {
|
||||
|
|
@ -13,10 +13,12 @@ pub struct UsrJayToplevel {
|
|||
pub con: Rc<UsrCon>,
|
||||
pub owner: CloneCell<Option<Rc<dyn UsrJayToplevelOwner>>>,
|
||||
pub version: Version,
|
||||
pub toplevel_id: RefCell<Option<String>>,
|
||||
}
|
||||
|
||||
pub trait UsrJayToplevelOwner {
|
||||
fn destroyed(&self) {}
|
||||
fn done(&self, tl: &Rc<UsrJayToplevel>);
|
||||
}
|
||||
|
||||
impl JayToplevelEventHandler for UsrJayToplevel {
|
||||
|
|
@ -28,6 +30,18 @@ impl JayToplevelEventHandler for UsrJayToplevel {
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn id_(&self, ev: Id<'_>, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
*self.toplevel_id.borrow_mut() = Some(ev.id.to_string());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn done(&self, _ev: Done, slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.done(slf);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue