From c8105ae1a67f78a7b31374eb390a89538064cc59 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Tue, 10 Oct 2023 12:42:24 +0400 Subject: Add screenshot-window action --- src/layout.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/layout.rs') 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 Layout { 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> { let MonitorSet::Normal { monitors, .. } = &self.monitor_set else { return None; -- cgit