diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2025-02-10 08:47:44 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2025-02-10 07:29:33 -0800 |
| commit | 55e2ea0c3bb0bccae351aa6e82987a0b77da54ae (patch) | |
| tree | d1d4d6ce033fe458e4be0cfdfaf3b04b76a7e442 /src/layout/mod.rs | |
| parent | 1d883931b4ae7704128f02fd566486fb02351196 (diff) | |
| download | niri-55e2ea0c3bb0bccae351aa6e82987a0b77da54ae.tar.gz niri-55e2ea0c3bb0bccae351aa6e82987a0b77da54ae.tar.bz2 niri-55e2ea0c3bb0bccae351aa6e82987a0b77da54ae.zip | |
layout: Extract tile.hit(), HitType::hit_tile()
Diffstat (limited to 'src/layout/mod.rs')
| -rw-r--r-- | src/layout/mod.rs | 21 |
1 files changed, 11 insertions, 10 deletions
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<W: LayoutElement>( + tile: &Tile<W>, + tile_pos: Point<f64, Logical>, + point: Point<f64, Logical>, + ) -> 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<W: LayoutElement> Layout<W> { 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)?; |
