diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2023-10-10 12:42:24 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2023-10-10 12:42:24 +0400 |
| commit | c8105ae1a67f78a7b31374eb390a89538064cc59 (patch) | |
| tree | 5eb764bb817e35923fe6ffd09fad0f465bb761f6 /src/layout.rs | |
| parent | cb73bcfb3248a5f5d2349d59790ed75c8431efcd (diff) | |
| download | niri-c8105ae1a67f78a7b31374eb390a89538064cc59.tar.gz niri-c8105ae1a67f78a7b31374eb390a89538064cc59.tar.bz2 niri-c8105ae1a67f78a7b31374eb390a89538064cc59.zip | |
Add screenshot-window action
Diffstat (limited to 'src/layout.rs')
| -rw-r--r-- | src/layout.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/layout.rs b/src/layout.rs index 003bb1c4..85d90bfb 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -751,6 +751,30 @@ impl<W: LayoutElement> Layout<W> { Some(&mon.workspaces[mon.active_workspace_idx]) } + pub fn active_window(&self) -> Option<(W, Output)> { + let MonitorSet::Normal { + monitors, + active_monitor_idx, + .. + } = &self.monitor_set + else { + return None; + }; + + let mon = &monitors[*active_monitor_idx]; + let ws = &mon.workspaces[mon.active_workspace_idx]; + + if ws.columns.is_empty() { + return None; + } + + let col = &ws.columns[ws.active_column_idx]; + Some(( + col.windows[col.active_window_idx].clone(), + mon.output.clone(), + )) + } + pub fn workspace_for_output(&self, output: &Output) -> Option<&Workspace<W>> { let MonitorSet::Normal { monitors, .. } = &self.monitor_set else { return None; |
