aboutsummaryrefslogtreecommitdiff
path: root/src/layout
diff options
context:
space:
mode:
authorrustysec <russ@infocyte.com>2024-05-16 14:30:52 -0700
committerIvan Molodetskikh <yalterz@gmail.com>2024-05-17 10:33:00 +0300
commit36d3e70f11bde96eb67d157b22ebcdf4767af0c2 (patch)
treef03cad743d95094e0d3eb37b26568006c5298806 /src/layout
parenta2f74c9bff953c9f3318cb642785f02c6f5fe5d3 (diff)
downloadniri-36d3e70f11bde96eb67d157b22ebcdf4767af0c2.tar.gz
niri-36d3e70f11bde96eb67d157b22ebcdf4767af0c2.tar.bz2
niri-36d3e70f11bde96eb67d157b22ebcdf4767af0c2.zip
Implement niri msg workspaces
Diffstat (limited to 'src/layout')
-rw-r--r--src/layout/mod.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs
index 544b2186..02eeda3b 100644
--- a/src/layout/mod.rs
+++ b/src/layout/mod.rs
@@ -2278,6 +2278,41 @@ impl<W: LayoutElement> Layout<W> {
}
}
}
+
+ pub fn ipc_workspaces(&self) -> Vec<niri_ipc::Workspace> {
+ match &self.monitor_set {
+ MonitorSet::Normal {
+ monitors,
+ primary_idx: _,
+ active_monitor_idx: _,
+ } => {
+ let mut workspaces = Vec::new();
+
+ for monitor in monitors {
+ for (idx, workspace) in monitor.workspaces.iter().enumerate() {
+ workspaces.push(niri_ipc::Workspace {
+ idx: u8::try_from(idx + 1).unwrap_or(u8::MAX),
+ name: workspace.name.clone(),
+ output: Some(monitor.output.name()),
+ is_active: monitor.active_workspace_idx == idx,
+ })
+ }
+ }
+
+ workspaces
+ }
+ MonitorSet::NoOutputs { workspaces } => workspaces
+ .iter()
+ .enumerate()
+ .map(|(idx, ws)| niri_ipc::Workspace {
+ idx: u8::try_from(idx + 1).unwrap_or(u8::MAX),
+ name: ws.name.clone(),
+ output: None,
+ is_active: false,
+ })
+ .collect(),
+ }
+ }
}
impl<W: LayoutElement> Default for MonitorSet<W> {