diff options
Diffstat (limited to 'src/layout/mod.rs')
| -rw-r--r-- | src/layout/mod.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 20c63d28..9a9e084d 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -836,6 +836,32 @@ impl<W: LayoutElement> Layout<W> { None } + pub fn find_workspace_by_id(&self, id: WorkspaceId) -> Option<(usize, &Workspace<W>)> { + match &self.monitor_set { + MonitorSet::Normal { ref monitors, .. } => { + for mon in monitors { + if let Some((index, workspace)) = mon + .workspaces + .iter() + .enumerate() + .find(|(_, w)| w.id() == id) + { + return Some((index, workspace)); + } + } + } + MonitorSet::NoOutputs { workspaces } => { + if let Some((index, workspace)) = + workspaces.iter().enumerate().find(|(_, w)| w.id() == id) + { + return Some((index, workspace)); + } + } + } + + None + } + pub fn find_workspace_by_name(&self, workspace_name: &str) -> Option<(usize, &Workspace<W>)> { match &self.monitor_set { MonitorSet::Normal { ref monitors, .. } => { |
