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>,
|
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)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct CaptureImage {
|
pub struct CaptureImage {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
|
|
||||||
|
|
@ -182,11 +182,7 @@ impl AppData {
|
||||||
.toplevels()
|
.toplevels()
|
||||||
.find(|info| info.foreign_toplevel == *toplevel);
|
.find(|info| info.foreign_toplevel == *toplevel);
|
||||||
if let Some(info) = info {
|
if let Some(info) = info {
|
||||||
info.workspace.iter().any(|workspace| {
|
self.capture_filter.toplevel_matches(info)
|
||||||
self.capture_filter
|
|
||||||
.toplevels_on_workspaces
|
|
||||||
.contains(workspace)
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
@ -197,9 +193,7 @@ impl AppData {
|
||||||
.find(|g| g.workspaces.iter().any(|w| w == workspace))
|
.find(|g| g.workspaces.iter().any(|w| w == workspace))
|
||||||
.is_some_and(|group| {
|
.is_some_and(|group| {
|
||||||
self.capture_filter
|
self.capture_filter
|
||||||
.workspaces_on_outputs
|
.workspace_outputs_matches(&group.outputs)
|
||||||
.iter()
|
|
||||||
.any(|o| group.outputs.contains(o))
|
|
||||||
}),
|
}),
|
||||||
CaptureSource::Output(_) => false,
|
CaptureSource::Output(_) => false,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue