diff --git a/cosmic-app-list/src/app.rs b/cosmic-app-list/src/app.rs index 7bb36b36..a4414f73 100755 --- a/cosmic-app-list/src/app.rs +++ b/cosmic-app-list/src/app.rs @@ -658,6 +658,12 @@ impl cosmic::Application for CosmicAppList { .chain(self.favorite_list.iter()) .find(|t| t.desktop_info.id == id) { + for (ref handle, _, _) in &toplevel_group.toplevels { + if let Some(tx) = self.wayland_sender.as_ref() { + let _ = tx.send(WaylandRequest::Screencopy(handle.clone())); + } + } + let rectangle = match self.rectangles.get(&toplevel_group.id) { Some(r) => r, None => return Command::none(), diff --git a/cosmic-app-list/src/wayland_handler.rs b/cosmic-app-list/src/wayland_handler.rs index 2a2821eb..5c0567fb 100644 --- a/cosmic-app-list/src/wayland_handler.rs +++ b/cosmic-app-list/src/wayland_handler.rs @@ -220,15 +220,13 @@ impl ToplevelInfoHandler for AppData { toplevel: &zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1, ) { if let Some(info) = self.toplevel_info_state.info(toplevel) { - // spawn thread for sending the image - self.send_image(toplevel.clone()); - let _ = self .tx .unbounded_send(WaylandUpdate::Toplevel(ToplevelUpdate::Add( toplevel.clone(), info.clone(), ))); + self.send_image(toplevel.clone()); } } @@ -239,8 +237,6 @@ impl ToplevelInfoHandler for AppData { toplevel: &zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1, ) { if let Some(info) = self.toplevel_info_state.info(toplevel) { - // spawn thread for sending the image - self.send_image(toplevel.clone()); let _ = self .tx .unbounded_send(WaylandUpdate::Toplevel(ToplevelUpdate::Update( @@ -615,6 +611,9 @@ pub(crate) fn wayland_handler( if handle .insert_source(rx, |event, _, state| match event { calloop::channel::Event::Msg(req) => match req { + WaylandRequest::Screencopy(handle) => { + state.send_image(handle.clone()); + } WaylandRequest::Toplevel(req) => match req { ToplevelRequest::Activate(handle) => { if let Some(seat) = state.seat_state.seats().next() { diff --git a/cosmic-app-list/src/wayland_subscription.rs b/cosmic-app-list/src/wayland_subscription.rs index e00e2dbe..a0e01e6c 100644 --- a/cosmic-app-list/src/wayland_subscription.rs +++ b/cosmic-app-list/src/wayland_subscription.rs @@ -128,6 +128,7 @@ pub enum WaylandRequest { exec: String, gpu_idx: Option, }, + Screencopy(ZcosmicToplevelHandleV1), } #[derive(Debug, Clone)]