forge
Explore
Log in

Don't you dare go Hollow

Refactor layer surface under cursor

Browse files at this commit

10905efeaf2de2865c619dfd086627031dedc998Ivan MolodetskikhParent: 7ff91fe
Prepare for varying the top layer position.
src/niri.rsmodified+22 -19
@@ -962,10 +962,9 @@ impl Niri {
962 }962 }
963 963
964 let layers = layer_map_for_output(output);964 let layers = layer_map_for_output(output);
965- let layer_surface = |first: Layer, second: Layer| {965+ let layer_surface_under = |layer| {
966 layers966 layers
967- .layer_under(first, pos_within_output)967+ .layer_under(layer, pos_within_output)
968- .or_else(|| layers.layer_under(second, pos_within_output))
969 .and_then(|layer| {968 .and_then(|layer| {
970 let layer_pos_within_output = layers.layer_geometry(layer).unwrap().loc;969 let layer_pos_within_output = layers.layer_geometry(layer).unwrap().loc;
971 layer970 layer
@@ -979,22 +978,26 @@ impl Niri {
979 })978 })
980 };979 };
981 980
982- let (surface, surface_pos_within_output) = layer_surface(Layer::Overlay, Layer::Top)981+ let window_under = || {
983- .or_else(|| {982+ self.layout
984- self.layout983+ .window_under(output, pos_within_output)
985- .window_under(output, pos_within_output)984+ .and_then(|(window, win_pos_within_output)| {
986- .and_then(|(window, win_pos_within_output)| {985+ window
987- window986+ .surface_under(
988- .surface_under(987+ pos_within_output - win_pos_within_output.to_f64(),
989- pos_within_output - win_pos_within_output.to_f64(),988+ WindowSurfaceType::ALL,
990- WindowSurfaceType::ALL,989+ )
991- )990+ .map(|(s, pos_within_window)| {
992- .map(|(s, pos_within_window)| {991+ (s, pos_within_window + win_pos_within_output)
993- (s, pos_within_window + win_pos_within_output)992+ })
994- })993+ })
995- })994+ };
996- })995+
997- .or_else(|| layer_surface(Layer::Bottom, Layer::Background))?;996+ let (surface, surface_pos_within_output) = layer_surface_under(Layer::Overlay)
997+ .or_else(|| layer_surface_under(Layer::Top))
998+ .or_else(window_under)
999+ .or_else(|| layer_surface_under(Layer::Bottom))
1000+ .or_else(|| layer_surface_under(Layer::Background))?;
998 1001
999 let output_pos_in_global_space = self.global_space.output_geometry(output).unwrap().loc;1002 let output_pos_in_global_space = self.global_space.output_geometry(output).unwrap().loc;
1000 let surface_loc_in_global_space = surface_pos_within_output + output_pos_in_global_space;1003 let surface_loc_in_global_space = surface_pos_within_output + output_pos_in_global_space;