From 4ca7c9fb5684705243b6df5e67188fc4e8f8d8a6 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Fri, 10 Feb 2023 13:41:08 -0800 Subject: [PATCH] Handle toplevel info updates --- src/main.rs | 9 ++++++++- src/wayland/mod.rs | 4 ++++ src/wayland/screencopy.rs | 2 ++ src/wayland/toplevel.rs | 5 +++-- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 01b18e5..90754e1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -329,6 +329,13 @@ impl Application for App { img: None, }); } + wayland::Event::UpdateToplevel(handle, info) => { + if let Some(toplevel) = + self.toplevels.iter_mut().find(|x| x.handle == handle) + { + toplevel.info = info; + } + } wayland::Event::CloseToplevel(handle) => { if let Some(idx) = self.toplevels.iter().position(|x| x.handle == handle) { self.toplevels.remove(idx); @@ -341,7 +348,7 @@ impl Application for App { } wayland::Event::ToplevelCapture(handle, image) => { if let Some(toplevel) = self.toplevel_for_handle_mut(&handle) { - println!("Got toplevel image!"); + //println!("Got toplevel image!"); toplevel.img = Some(image); } } diff --git a/src/wayland/mod.rs b/src/wayland/mod.rs index c731ea3..61e3049 100644 --- a/src/wayland/mod.rs +++ b/src/wayland/mod.rs @@ -67,6 +67,10 @@ pub enum Event { zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1, ToplevelInfo, ), + UpdateToplevel( + zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1, + ToplevelInfo, + ), CloseToplevel(zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1), ToplevelCapture( zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1, diff --git a/src/wayland/screencopy.rs b/src/wayland/screencopy.rs index 3d7b2f1..d52ead1 100644 --- a/src/wayland/screencopy.rs +++ b/src/wayland/screencopy.rs @@ -93,6 +93,8 @@ impl ScreencopyHandler for AppData { ) { // TODO println!("Failed"); + let capture = Capture::for_session(session).unwrap(); + capture.cancel(); session.destroy(); } } diff --git a/src/wayland/toplevel.rs b/src/wayland/toplevel.rs index 8c6ef97..e7dc293 100644 --- a/src/wayland/toplevel.rs +++ b/src/wayland/toplevel.rs @@ -32,9 +32,10 @@ impl ToplevelInfoHandler for AppData { &mut self, _conn: &Connection, _qh: &QueueHandle, - _toplevel: &zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1, + toplevel: &zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1, ) { - // TODO + let info = self.toplevel_info_state.info(toplevel).unwrap(); + self.send_event(Event::UpdateToplevel(toplevel.clone(), info.clone())); } fn toplevel_closed(