mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-23 02:05:33 +07:00
Refactor layer surface under cursor
Prepare for varying the top layer position.
This commit is contained in:
+22
-19
@@ -962,10 +962,9 @@ impl Niri {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let layers = layer_map_for_output(output);
|
let layers = layer_map_for_output(output);
|
||||||
let layer_surface = |first: Layer, second: Layer| {
|
let layer_surface_under = |layer| {
|
||||||
layers
|
layers
|
||||||
.layer_under(first, pos_within_output)
|
.layer_under(layer, pos_within_output)
|
||||||
.or_else(|| layers.layer_under(second, pos_within_output))
|
|
||||||
.and_then(|layer| {
|
.and_then(|layer| {
|
||||||
let layer_pos_within_output = layers.layer_geometry(layer).unwrap().loc;
|
let layer_pos_within_output = layers.layer_geometry(layer).unwrap().loc;
|
||||||
layer
|
layer
|
||||||
@@ -979,22 +978,26 @@ impl Niri {
|
|||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
let (surface, surface_pos_within_output) = layer_surface(Layer::Overlay, Layer::Top)
|
let window_under = || {
|
||||||
.or_else(|| {
|
self.layout
|
||||||
self.layout
|
.window_under(output, pos_within_output)
|
||||||
.window_under(output, pos_within_output)
|
.and_then(|(window, win_pos_within_output)| {
|
||||||
.and_then(|(window, win_pos_within_output)| {
|
window
|
||||||
window
|
.surface_under(
|
||||||
.surface_under(
|
pos_within_output - win_pos_within_output.to_f64(),
|
||||||
pos_within_output - win_pos_within_output.to_f64(),
|
WindowSurfaceType::ALL,
|
||||||
WindowSurfaceType::ALL,
|
)
|
||||||
)
|
.map(|(s, pos_within_window)| {
|
||||||
.map(|(s, pos_within_window)| {
|
(s, pos_within_window + win_pos_within_output)
|
||||||
(s, pos_within_window + win_pos_within_output)
|
})
|
||||||
})
|
})
|
||||||
})
|
};
|
||||||
})
|
|
||||||
.or_else(|| layer_surface(Layer::Bottom, Layer::Background))?;
|
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 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;
|
let surface_loc_in_global_space = surface_pos_within_output + output_pos_in_global_space;
|
||||||
|
|||||||
Reference in New Issue
Block a user