diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2023-11-02 13:01:34 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2023-11-02 13:01:34 +0400 |
| commit | 10905efeaf2de2865c619dfd086627031dedc998 (patch) | |
| tree | d3ec5a5beda008c9a001551bbaac68e49f11f15c /src/niri.rs | |
| parent | 7ff91fe39423c9ffbef5da9644d5567b3a3c07c4 (diff) | |
| download | niri-10905efeaf2de2865c619dfd086627031dedc998.tar.gz niri-10905efeaf2de2865c619dfd086627031dedc998.tar.bz2 niri-10905efeaf2de2865c619dfd086627031dedc998.zip | |
Refactor layer surface under cursor
Prepare for varying the top layer position.
Diffstat (limited to 'src/niri.rs')
| -rw-r--r-- | src/niri.rs | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/src/niri.rs b/src/niri.rs index 8e10f299..0b77de93 100644 --- a/src/niri.rs +++ b/src/niri.rs @@ -962,10 +962,9 @@ impl Niri { } let layers = layer_map_for_output(output); - let layer_surface = |first: Layer, second: Layer| { + let layer_surface_under = |layer| { layers - .layer_under(first, pos_within_output) - .or_else(|| layers.layer_under(second, pos_within_output)) + .layer_under(layer, pos_within_output) .and_then(|layer| { let layer_pos_within_output = layers.layer_geometry(layer).unwrap().loc; layer @@ -979,22 +978,26 @@ impl Niri { }) }; - let (surface, surface_pos_within_output) = layer_surface(Layer::Overlay, Layer::Top) - .or_else(|| { - self.layout - .window_under(output, pos_within_output) - .and_then(|(window, win_pos_within_output)| { - window - .surface_under( - pos_within_output - win_pos_within_output.to_f64(), - WindowSurfaceType::ALL, - ) - .map(|(s, pos_within_window)| { - (s, pos_within_window + win_pos_within_output) - }) - }) - }) - .or_else(|| layer_surface(Layer::Bottom, Layer::Background))?; + let window_under = || { + self.layout + .window_under(output, pos_within_output) + .and_then(|(window, win_pos_within_output)| { + window + .surface_under( + pos_within_output - win_pos_within_output.to_f64(), + WindowSurfaceType::ALL, + ) + .map(|(s, pos_within_window)| { + (s, pos_within_window + win_pos_within_output) + }) + }) + }; + + let (surface, surface_pos_within_output) = layer_surface_under(Layer::Overlay) + .or_else(|| layer_surface_under(Layer::Top)) + .or_else(window_under) + .or_else(|| layer_surface_under(Layer::Bottom)) + .or_else(|| layer_surface_under(Layer::Background))?; let output_pos_in_global_space = self.global_space.output_geometry(output).unwrap().loc; let surface_loc_in_global_space = surface_pos_within_output + output_pos_in_global_space; |
