From 20b694386de4dbb16b05f46b0cf7ebfe4ebb087b Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Wed, 4 Jun 2025 09:43:34 -0700 Subject: [PATCH] Drop capture received from backend if it no longer matches filter --- src/main.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 679c026..ed30f84 100644 --- a/src/main.rs +++ b/src/main.rs @@ -178,6 +178,7 @@ struct Conf { #[derive(Default)] struct App { + capture_filter: backend::CaptureFilter, layer_surfaces: HashMap, outputs: Vec, workspaces: Vec, @@ -327,6 +328,7 @@ impl App { } } + self.capture_filter = capture_filter.clone(); self.send_wayland_cmd(backend::Cmd::CaptureFilter(capture_filter)); } } @@ -485,14 +487,20 @@ impl Application for App { } backend::Event::WorkspaceCapture(handle, image) => { //println!("Workspace capture"); + let capture_filter = self.capture_filter.clone(); // XXX if let Some(workspace) = self.workspace_for_handle_mut(&handle) { - workspace.img = Some(image); + if capture_filter.workspace_outputs_matches(&workspace.outputs) { + workspace.img = Some(image); + } } } backend::Event::ToplevelCapture(handle, image) => { + let capture_filter = self.capture_filter.clone(); // XXX if let Some(toplevel) = self.toplevel_for_handle_mut(&handle) { // println!("Got toplevel image!"); - toplevel.img = Some(image); + if capture_filter.toplevel_matches(&toplevel.info) { + toplevel.img = Some(image); + } } } backend::Event::ToplevelCapabilities(capabilities) => {