@@ -90,7 +90,7 @@ pub struct ToplevelHandleStateInner<W: Window> {
9090 title : String ,
9191 app_id : String ,
9292 states : Vec < States > ,
93- pub ( super ) window : W ,
93+ pub ( super ) window : Option < W > ,
9494}
9595pub type ToplevelHandleState < W > = Mutex < ToplevelHandleStateInner < W > > ;
9696
@@ -104,7 +104,20 @@ impl<W: Window> ToplevelHandleStateInner<W> {
104104 title : String :: new ( ) ,
105105 app_id : String :: new ( ) ,
106106 states : Vec :: new ( ) ,
107- window : window. clone ( ) ,
107+ window : Some ( window. clone ( ) ) ,
108+ } )
109+ }
110+
111+ fn empty ( ) -> ToplevelHandleState < W > {
112+ ToplevelHandleState :: new ( ToplevelHandleStateInner {
113+ outputs : Vec :: new ( ) ,
114+ geometry : None ,
115+ wl_outputs : HashSet :: new ( ) ,
116+ workspaces : Vec :: new ( ) ,
117+ title : String :: new ( ) ,
118+ app_id : String :: new ( ) ,
119+ states : Vec :: new ( ) ,
120+ window : None ,
108121 } )
109122 }
110123}
@@ -187,6 +200,10 @@ where
187200 . instances
188201 . push ( instance) ;
189202 } else {
203+ let _ = data_init. init (
204+ cosmic_toplevel,
205+ ToplevelHandleStateInner :: empty ( ) ,
206+ ) ;
190207 error ! ( ?foreign_toplevel, "Toplevel for foreign-toplevel-list not registered for cosmic-toplevel-info." ) ;
191208 }
192209 }
@@ -600,7 +617,7 @@ where
600617pub fn window_from_handle < W : Window + ' static > ( handle : ZcosmicToplevelHandleV1 ) -> Option < W > {
601618 handle
602619 . data :: < ToplevelHandleState < W > > ( )
603- . map ( |state| state. lock ( ) . unwrap ( ) . window . clone ( ) )
620+ . and_then ( |state| state. lock ( ) . unwrap ( ) . window . clone ( ) )
604621}
605622
606623macro_rules! delegate_toplevel_info {
0 commit comments