diff --git a/src/wayland/protocols/toplevel_info.rs b/src/wayland/protocols/toplevel_info.rs index 48b9e483..356d6ccf 100644 --- a/src/wayland/protocols/toplevel_info.rs +++ b/src/wayland/protocols/toplevel_info.rs @@ -90,7 +90,7 @@ pub struct ToplevelHandleStateInner { title: String, app_id: String, states: Vec, - pub(super) window: W, + pub(super) window: Option, } pub type ToplevelHandleState = Mutex>; @@ -104,7 +104,20 @@ impl ToplevelHandleStateInner { title: String::new(), app_id: String::new(), states: Vec::new(), - window: window.clone(), + window: Some(window.clone()), + }) + } + + fn empty() -> ToplevelHandleState { + ToplevelHandleState::new(ToplevelHandleStateInner { + outputs: Vec::new(), + geometry: None, + wl_outputs: HashSet::new(), + workspaces: Vec::new(), + title: String::new(), + app_id: String::new(), + states: Vec::new(), + window: None, }) } } @@ -187,6 +200,10 @@ where .instances .push(instance); } else { + let _ = data_init.init( + cosmic_toplevel, + ToplevelHandleStateInner::empty(), + ); error!(?foreign_toplevel, "Toplevel for foreign-toplevel-list not registered for cosmic-toplevel-info."); } } @@ -600,7 +617,7 @@ where pub fn window_from_handle(handle: ZcosmicToplevelHandleV1) -> Option { handle .data::>() - .map(|state| state.lock().unwrap().window.clone()) + .and_then(|state| state.lock().unwrap().window.clone()) } macro_rules! delegate_toplevel_info {