improv(app-list): only send screencopy requests as needed

This commit is contained in:
Ryan Brue 2024-04-01 19:53:58 -05:00 committed by Michael Murphy
parent 2f1b20e1c7
commit 769af3d944
3 changed files with 11 additions and 5 deletions

View file

@ -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(),

View file

@ -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() {

View file

@ -128,6 +128,7 @@ pub enum WaylandRequest {
exec: String,
gpu_idx: Option<usize>,
},
Screencopy(ZcosmicToplevelHandleV1),
}
#[derive(Debug, Clone)]