diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2025-04-24 22:04:49 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2025-04-25 02:00:18 -0700 |
| commit | 395b6d9a4f05176ad2a54e5c59a697f9d0c54cd9 (patch) | |
| tree | 1e78c6bb2459ba68d82d8bc19c49f289bac34fe5 /src/layout | |
| parent | 25f24f668cf4ebdaa6a886e1eaed7cab3c8f1483 (diff) | |
| download | niri-395b6d9a4f05176ad2a54e5c59a697f9d0c54cd9.tar.gz niri-395b6d9a4f05176ad2a54e5c59a697f9d0c54cd9.tar.bz2 niri-395b6d9a4f05176ad2a54e5c59a697f9d0c54cd9.zip | |
layout: Extract interactive_moved_window_under() and add output check
Fixes interactively moved window getting input on every output rather
than just its own.
Diffstat (limited to 'src/layout')
| -rw-r--r-- | src/layout/mod.rs | 22 |
1 files changed, 17 insertions, 5 deletions
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<W: LayoutElement> Layout<W> { mon.active_window().map(|win| (win, &mon.output)) } + pub fn interactive_moved_window_under( + &self, + output: &Output, + pos_within_output: Point<f64, Logical>, + ) -> 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<W: LayoutElement> Layout<W> { 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) } |
