diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2025-04-24 21:36:47 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2025-04-25 02:00:18 -0700 |
| commit | 25f24f668cf4ebdaa6a886e1eaed7cab3c8f1483 (patch) | |
| tree | a9f1dbf0e3b3bd0a00b8432b7fe0a5bebed2fcd6 | |
| parent | 929eaf0d694a9f0e8aa9b436004f0d054c9e2919 (diff) | |
| download | niri-25f24f668cf4ebdaa6a886e1eaed7cab3c8f1483.tar.gz niri-25f24f668cf4ebdaa6a886e1eaed7cab3c8f1483.tar.bz2 niri-25f24f668cf4ebdaa6a886e1eaed7cab3c8f1483.zip | |
Extract mapped_hit_data()
| -rw-r--r-- | src/niri.rs | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/src/niri.rs b/src/niri.rs index f893bb33..52b1ec09 100644 --- a/src/niri.rs +++ b/src/niri.rs @@ -2990,26 +2990,28 @@ impl Niri { let layer_toplevel_under = |layer| layer_surface_under(layer, false); let layer_popup_under = |layer| layer_surface_under(layer, true); + let mapped_hit_data = |(mapped, hit): (&Mapped, HitType)| { + let window = &mapped.window; + let surface_and_pos = if let HitType::Input { win_pos } = hit { + let win_pos_within_output = win_pos; + window + .surface_under( + pos_within_output - win_pos_within_output, + WindowSurfaceType::ALL, + ) + .map(|(s, pos_within_window)| { + (s, pos_within_window.to_f64() + win_pos_within_output) + }) + } else { + None + }; + (surface_and_pos, (Some((window.clone(), hit)), None)) + }; + let window_under = || { self.layout .window_under(output, pos_within_output) - .map(|(mapped, hit)| { - let window = &mapped.window; - let surface_and_pos = if let HitType::Input { win_pos } = hit { - let win_pos_within_output = win_pos; - window - .surface_under( - pos_within_output - win_pos_within_output, - WindowSurfaceType::ALL, - ) - .map(|(s, pos_within_window)| { - (s, pos_within_window.to_f64() + win_pos_within_output) - }) - } else { - None - }; - (surface_and_pos, (Some((window.clone(), hit)), None)) - }) + .map(mapped_hit_data) }; let mon = self.layout.monitor_for_output(output).unwrap(); |
