From 55e2ea0c3bb0bccae351aa6e82987a0b77da54ae Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Mon, 10 Feb 2025 08:47:44 +0300 Subject: layout: Extract tile.hit(), HitType::hit_tile() --- src/layout/mod.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/layout/mod.rs') diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 593279b7..4e0dbf93 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -507,6 +507,16 @@ impl HitType { } self } + + pub fn hit_tile( + tile: &Tile, + tile_pos: Point, + point: Point, + ) -> Option<(&W, Self)> { + let pos_within_tile = point - tile_pos; + tile.hit(pos_within_tile) + .map(|hit| (tile.window(), hit.offset_win_pos(tile_pos))) + } } impl Options { @@ -2191,16 +2201,7 @@ impl Layout { if let Some(InteractiveMoveState::Moving(move_)) = &self.interactive_move { let tile_pos = move_.tile_render_location(); - let pos_within_tile = pos_within_output - tile_pos; - - if move_.tile.is_in_input_region(pos_within_tile) { - let win_pos = tile_pos + move_.tile.buf_loc(); - return Some((move_.tile.window(), HitType::Input { win_pos })); - } else if move_.tile.is_in_activation_region(pos_within_tile) { - return Some((move_.tile.window(), HitType::Activate)); - } - - return None; + return HitType::hit_tile(&move_.tile, tile_pos, pos_within_output); }; let mon = monitors.iter().find(|mon| &mon.output == output)?; -- cgit