From 395b6d9a4f05176ad2a54e5c59a697f9d0c54cd9 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Thu, 24 Apr 2025 22:04:49 +0300 Subject: layout: Extract interactive_moved_window_under() and add output check Fixes interactively moved window getting input on every output rather than just its own. --- src/layout/mod.rs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'src/layout') diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 9347fc73..040a5cb4 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -2272,6 +2272,23 @@ impl Layout { mon.active_window().map(|win| (win, &mon.output)) } + pub fn interactive_moved_window_under( + &self, + output: &Output, + pos_within_output: Point, + ) -> Option<(&W, HitType)> { + if let Some(InteractiveMoveState::Moving(move_)) = &self.interactive_move { + if move_.output == *output { + let tile_pos = move_.tile_render_location(1.); + HitType::hit_tile(&move_.tile, tile_pos, pos_within_output) + } else { + None + } + } else { + None + } + } + /// Returns the window under the cursor and the hit type. pub fn window_under( &self, @@ -2282,11 +2299,6 @@ impl Layout { return None; }; - if let Some(InteractiveMoveState::Moving(move_)) = &self.interactive_move { - let tile_pos = move_.tile_render_location(); - return HitType::hit_tile(&move_.tile, tile_pos, pos_within_output); - }; - let mon = monitors.iter().find(|mon| &mon.output == output)?; mon.window_under(pos_within_output) } -- cgit