mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-23 02:05:33 +07:00
pointer input for layer surface
This commit is contained in:
committed by
Ivan Molodetskikh
parent
ee8404b9a9
commit
e7857efbd2
+38
-13
@@ -939,10 +939,9 @@ impl Niri {
|
|||||||
pos: Point<f64, Logical>,
|
pos: Point<f64, Logical>,
|
||||||
) -> Option<PointerFocus> {
|
) -> Option<PointerFocus> {
|
||||||
let (output, pos_within_output) = self.output_under(pos)?;
|
let (output, pos_within_output) = self.output_under(pos)?;
|
||||||
let output = output.clone();
|
|
||||||
|
|
||||||
if self.is_locked() {
|
if self.is_locked() {
|
||||||
let state = self.output_state.get(&output)?;
|
let state = self.output_state.get(output)?;
|
||||||
let surface = state.lock_surface.as_ref()?;
|
let surface = state.lock_surface.as_ref()?;
|
||||||
// We put lock surfaces at (0, 0).
|
// We put lock surfaces at (0, 0).
|
||||||
let point = pos_within_output;
|
let point = pos_within_output;
|
||||||
@@ -953,7 +952,7 @@ impl Niri {
|
|||||||
WindowSurfaceType::ALL,
|
WindowSurfaceType::ALL,
|
||||||
)?;
|
)?;
|
||||||
return Some(PointerFocus {
|
return Some(PointerFocus {
|
||||||
output,
|
output: output.clone(),
|
||||||
surface: (surface, point),
|
surface: (surface, point),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -962,20 +961,46 @@ impl Niri {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let (window, win_pos_within_output) =
|
let layers = layer_map_for_output(output);
|
||||||
self.layout.window_under(&output, pos_within_output)?;
|
let layer_surface = |first: Layer, second: Layer| {
|
||||||
|
layers
|
||||||
|
.layer_under(first, pos_within_output)
|
||||||
|
.or_else(|| layers.layer_under(second, pos_within_output))
|
||||||
|
.and_then(|layer| {
|
||||||
|
let layer_pos_within_output = layers.layer_geometry(layer).unwrap().loc;
|
||||||
|
layer
|
||||||
|
.surface_under(
|
||||||
|
pos_within_output - layer_pos_within_output.to_f64(),
|
||||||
|
WindowSurfaceType::ALL,
|
||||||
|
)
|
||||||
|
.map(|(surface, pos_within_layer)| {
|
||||||
|
(surface, pos_within_layer + layer_pos_within_output)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
let (surface, surface_pos_within_output) = window
|
let (surface, surface_pos_within_output) = layer_surface(Layer::Overlay, Layer::Top)
|
||||||
.surface_under(
|
.or_else(|| {
|
||||||
pos_within_output - win_pos_within_output.to_f64(),
|
self.layout
|
||||||
WindowSurfaceType::ALL,
|
.window_under(output, pos_within_output)
|
||||||
)
|
.and_then(|(window, win_pos_within_output)| {
|
||||||
.map(|(s, pos_within_window)| (s, pos_within_window + win_pos_within_output))?;
|
window
|
||||||
let output_pos_in_global_space = self.global_space.output_geometry(&output).unwrap().loc;
|
.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 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;
|
||||||
|
|
||||||
Some(PointerFocus {
|
Some(PointerFocus {
|
||||||
output,
|
output: output.clone(),
|
||||||
surface: (surface, surface_loc_in_global_space),
|
surface: (surface, surface_loc_in_global_space),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user