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 | |
| 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')
| -rw-r--r-- | src/layout/mod.rs | 22 | ||||
| -rw-r--r-- | src/niri.rs | 14 |
2 files changed, 31 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) } diff --git a/src/niri.rs b/src/niri.rs index 52b1ec09..c4472a52 100644 --- a/src/niri.rs +++ b/src/niri.rs @@ -2902,6 +2902,13 @@ impl Niri { return None; } + if let Some((window, _loc)) = self + .layout + .interactive_moved_window_under(output, pos_within_output) + { + return Some(window); + } + let (window, _loc) = self.layout.window_under(output, pos_within_output)?; Some(window) } @@ -3008,6 +3015,11 @@ impl Niri { (surface_and_pos, (Some((window.clone(), hit)), None)) }; + let interactive_moved_window_under = || { + self.layout + .interactive_moved_window_under(output, pos_within_output) + .map(mapped_hit_data) + }; let window_under = || { self.layout .window_under(output, pos_within_output) @@ -3023,6 +3035,7 @@ impl Niri { // Otherwise, we will render all layer-shell pop-ups and the top layer on top. if mon.render_above_top_layer() { under = under + .or_else(interactive_moved_window_under) .or_else(window_under) .or_else(|| layer_popup_under(Layer::Top)) .or_else(|| layer_toplevel_under(Layer::Top)) @@ -3036,6 +3049,7 @@ impl Niri { .or_else(|| layer_toplevel_under(Layer::Top)) .or_else(|| layer_popup_under(Layer::Bottom)) .or_else(|| layer_popup_under(Layer::Background)) + .or_else(interactive_moved_window_under) .or_else(window_under) .or_else(|| layer_toplevel_under(Layer::Bottom)) .or_else(|| layer_toplevel_under(Layer::Background)); |
