input: Rework PointerFocus to operate directly on WlSurface
This commit is contained in:
parent
4579cca6fa
commit
5459f52d5e
12 changed files with 619 additions and 1107 deletions
|
|
@ -686,7 +686,13 @@ impl FloatingLayout {
|
|||
self.space.element_geometry(elem).map(RectExt::as_local)
|
||||
}
|
||||
|
||||
pub fn element_under(
|
||||
pub fn element_under(&mut self, location: Point<f64, Local>) -> Option<KeyboardFocusTarget> {
|
||||
self.space
|
||||
.element_under(location.as_logical())
|
||||
.map(|(mapped, _)| mapped.clone().into())
|
||||
}
|
||||
|
||||
pub fn surface_under(
|
||||
&mut self,
|
||||
location: Point<f64, Local>,
|
||||
) -> Option<(PointerFocusTarget, Point<i32, Local>)> {
|
||||
|
|
@ -694,6 +700,7 @@ impl FloatingLayout {
|
|||
.space
|
||||
.element_under(location.as_logical())
|
||||
.map(|(mapped, p)| (mapped.clone(), p.as_local()));
|
||||
|
||||
if let Some((mapped, _)) = res.as_ref() {
|
||||
let geometry = self.space.element_geometry(mapped).unwrap();
|
||||
let offset = location.y.round() as i32 - geometry.loc.y;
|
||||
|
|
@ -705,7 +712,16 @@ impl FloatingLayout {
|
|||
} else {
|
||||
self.hovered_stack.take();
|
||||
}
|
||||
res.map(|(m, p)| (m.into(), p))
|
||||
|
||||
res.and_then(|(element, space_offset)| {
|
||||
let geometry = self.space.element_geometry(&element).unwrap().as_local();
|
||||
let point = location - geometry.loc.to_f64();
|
||||
element
|
||||
.focus_under(point.as_logical())
|
||||
.map(|(surface, surface_offset)| {
|
||||
(surface, space_offset + surface_offset.as_local())
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
pub fn stacking_indicator(&self) -> Option<Rectangle<i32, Local>> {
|
||||
|
|
|
|||
|
|
@ -3088,6 +3088,26 @@ impl TilingLayout {
|
|||
pub fn element_under(
|
||||
&mut self,
|
||||
location_f64: Point<f64, Local>,
|
||||
) -> Option<KeyboardFocusTarget> {
|
||||
let location = location_f64.to_i32_round();
|
||||
|
||||
for (mapped, geo) in self.mapped() {
|
||||
if !mapped.bbox().contains((location - geo.loc).as_logical()) {
|
||||
continue;
|
||||
}
|
||||
if mapped.is_in_input_region(
|
||||
&((location_f64 - geo.loc.to_f64()).as_logical() + mapped.geometry().loc.to_f64()),
|
||||
) {
|
||||
return Some(mapped.clone().into());
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
pub fn surface_under(
|
||||
&mut self,
|
||||
location_f64: Point<f64, Local>,
|
||||
overview: OverviewMode,
|
||||
) -> Option<(PointerFocusTarget, Point<i32, Local>)> {
|
||||
let gaps = self.gaps();
|
||||
|
|
@ -3115,13 +3135,12 @@ impl TilingLayout {
|
|||
if !mapped.bbox().contains((location - geo.loc).as_logical()) {
|
||||
continue;
|
||||
}
|
||||
if mapped.is_in_input_region(
|
||||
&((location_f64 - geo.loc.to_f64()).as_logical()
|
||||
+ mapped.geometry().loc.to_f64()),
|
||||
if let Some((target, surface_offset)) = mapped.focus_under(
|
||||
(location_f64 - geo.loc.to_f64()).as_logical() + mapped.geometry().loc.to_f64(),
|
||||
) {
|
||||
return Some((
|
||||
mapped.clone().into(),
|
||||
geo.loc - mapped.geometry().loc.as_local(),
|
||||
target,
|
||||
geo.loc - mapped.geometry().loc.as_local() + surface_offset.as_local(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
@ -3163,12 +3182,15 @@ impl TilingLayout {
|
|||
let test_point = (location.to_f64() - last_geometry.loc.to_f64()
|
||||
+ mapped.geometry().loc.to_f64().as_local())
|
||||
.as_logical();
|
||||
mapped.is_in_input_region(&test_point).then(|| {
|
||||
(
|
||||
mapped.clone().into(),
|
||||
last_geometry.loc - mapped.geometry().loc.as_local(),
|
||||
)
|
||||
})
|
||||
mapped
|
||||
.focus_under(test_point)
|
||||
.map(|(surface, surface_offset)| {
|
||||
(
|
||||
surface,
|
||||
last_geometry.loc - mapped.geometry().loc.as_local()
|
||||
+ surface_offset.as_local(),
|
||||
)
|
||||
})
|
||||
}
|
||||
Some((
|
||||
id,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue