mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-22 02:01:55 +07:00
Implement by-id workspace action addressing
It's not added to clap because there's no convenient mutually-exclusive argument enum derive yet (to have either the current <REFERENCE> or an --id <ID>). It's not added to config parsing because I don't see how it could be useful there. As such, it's only accessible through raw IPC.
This commit is contained in:
@@ -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, .. } => {
|
||||
|
||||
Reference in New Issue
Block a user