From c41f93a468c4d04e16f8c89736cc48cd4ab4c623 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Wed, 5 Feb 2025 17:18:21 +0300 Subject: Add focus-window-top/bottom/down-or-top/up-or-bottom actions --- src/layout/floating.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/layout/floating.rs') diff --git a/src/layout/floating.rs b/src/layout/floating.rs index b908d920..15c99e87 100644 --- a/src/layout/floating.rs +++ b/src/layout/floating.rs @@ -833,6 +833,26 @@ impl FloatingSpace { } } + pub fn focus_topmost(&mut self) { + let result = self + .tiles_with_offsets() + .min_by(|(_, pos_a), (_, pos_b)| f64::total_cmp(&pos_a.y, &pos_b.y)); + if let Some((tile, _)) = result { + let id = tile.window().id().clone(); + self.activate_window(&id); + } + } + + pub fn focus_bottommost(&mut self) { + let result = self + .tiles_with_offsets() + .max_by(|(_, pos_a), (_, pos_b)| f64::total_cmp(&pos_a.y, &pos_b.y)); + if let Some((tile, _)) = result { + let id = tile.window().id().clone(); + self.activate_window(&id); + } + } + fn move_to(&mut self, idx: usize, new_pos: Point, animate: bool) { if animate { self.move_and_animate(idx, new_pos); -- cgit