Helper methods on CatpureFilter for matching
Could be prettier, but want some way to check this in multiple places.
This commit is contained in:
parent
6fd237ac39
commit
a863e8f7d6
2 changed files with 19 additions and 8 deletions
|
|
@ -44,6 +44,23 @@ pub struct CaptureFilter {
|
|||
pub toplevels_on_workspaces: Vec<ExtWorkspaceHandleV1>,
|
||||
}
|
||||
|
||||
impl CaptureFilter {
|
||||
pub fn workspace_outputs_matches<'a>(
|
||||
&self,
|
||||
outputs: impl IntoIterator<Item = &'a wl_output::WlOutput>,
|
||||
) -> bool {
|
||||
outputs
|
||||
.into_iter()
|
||||
.any(|o| self.workspaces_on_outputs.contains(o))
|
||||
}
|
||||
|
||||
pub fn toplevel_matches(&self, info: &ToplevelInfo) -> bool {
|
||||
info.workspace
|
||||
.iter()
|
||||
.any(|workspace| self.toplevels_on_workspaces.contains(workspace))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct CaptureImage {
|
||||
#[allow(dead_code)]
|
||||
|
|
|
|||
|
|
@ -182,11 +182,7 @@ impl AppData {
|
|||
.toplevels()
|
||||
.find(|info| info.foreign_toplevel == *toplevel);
|
||||
if let Some(info) = info {
|
||||
info.workspace.iter().any(|workspace| {
|
||||
self.capture_filter
|
||||
.toplevels_on_workspaces
|
||||
.contains(workspace)
|
||||
})
|
||||
self.capture_filter.toplevel_matches(info)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
|
@ -197,9 +193,7 @@ impl AppData {
|
|||
.find(|g| g.workspaces.iter().any(|w| w == workspace))
|
||||
.is_some_and(|group| {
|
||||
self.capture_filter
|
||||
.workspaces_on_outputs
|
||||
.iter()
|
||||
.any(|o| group.outputs.contains(o))
|
||||
.workspace_outputs_matches(&group.outputs)
|
||||
}),
|
||||
CaptureSource::Output(_) => false,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue