From bfd81fc2904ba35ae7ccb979e8cb4b2d244fb2dd Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Wed, 5 Feb 2025 10:08:56 +0300 Subject: Make send_frame() a function on Mapped We'll add some extra logic there. --- src/layout/mod.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/layout') diff --git a/src/layout/mod.rs b/src/layout/mod.rs index a49ec0e6..ae338ced 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -476,6 +476,13 @@ impl InteractiveMoveState { _ => None, } } + + fn moving_mut(&mut self) -> Option<&mut InteractiveMoveData> { + match self { + InteractiveMoveState::Moving(move_) => Some(move_), + _ => None, + } + } } impl InteractiveMoveData { @@ -1608,6 +1615,28 @@ impl Layout { moving_window.chain(mon_windows) } + pub fn windows_for_output_mut(&mut self, output: &Output) -> impl Iterator + '_ { + let MonitorSet::Normal { monitors, .. } = &mut self.monitor_set else { + panic!() + }; + + let moving_window = self + .interactive_move + .as_mut() + .and_then(|x| x.moving_mut()) + .filter(|move_| move_.output == *output) + .map(|move_| move_.tile.window_mut()) + .into_iter(); + + let mon = monitors + .iter_mut() + .find(|mon| &mon.output == output) + .unwrap(); + let mon_windows = mon.workspaces.iter_mut().flat_map(|ws| ws.windows_mut()); + + moving_window.chain(mon_windows) + } + pub fn with_windows(&self, mut f: impl FnMut(&W, Option<&Output>, Option)) { if let Some(InteractiveMoveState::Moving(move_)) = &self.interactive_move { f(move_.tile.window(), Some(&move_.output), None); -- cgit