mirror of
https://github.com/pinnacle-comp/pinnacle.git
synced 2025-01-26 19:58:01 +01:00
Ignore non-rendered windows for input
This commit is contained in:
parent
15e03b6c17
commit
41ea5e5230
4 changed files with 27 additions and 3 deletions
19
src/input.rs
19
src/input.rs
|
@ -73,6 +73,7 @@ impl State {
|
|||
}
|
||||
}
|
||||
|
||||
/// Get the [`FocusTarget`] under `point`.
|
||||
pub fn surface_under<P>(&self, point: P) -> Option<(FocusTarget, Point<i32, Logical>)>
|
||||
where
|
||||
P: Into<Point<f64, Logical>>,
|
||||
|
@ -114,8 +115,22 @@ impl State {
|
|||
})
|
||||
.or_else(|| {
|
||||
self.space
|
||||
.element_under(point)
|
||||
.map(|(window, loc)| (window.clone().into(), loc))
|
||||
.elements()
|
||||
.rev()
|
||||
.filter(|win| win.is_on_active_tag(self.space.outputs()))
|
||||
.find_map(|win| {
|
||||
let loc = self
|
||||
.space
|
||||
.element_location(win)
|
||||
.expect("called elem loc on unmapped win")
|
||||
- win.geometry().loc;
|
||||
|
||||
if win.is_in_input_region(&(point - loc.to_f64())) {
|
||||
Some((win.clone().into(), loc))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
})
|
||||
.or_else(|| {
|
||||
layers
|
||||
|
|
|
@ -226,7 +226,7 @@ where
|
|||
Tag::tag_render_elements(&tags, windows, space, renderer);
|
||||
|
||||
let mut output_render_elements =
|
||||
Vec::<OutputRenderElements<_, WaylandSurfaceRenderElement<_>>>::new();
|
||||
Vec::<OutputRenderElements<R, WaylandSurfaceRenderElement<R>>>::new();
|
||||
|
||||
output_render_elements.extend(
|
||||
custom_render_elements
|
||||
|
|
|
@ -141,6 +141,7 @@ impl Tag {
|
|||
})
|
||||
})
|
||||
.flat_map(|win| {
|
||||
// subtract win.geometry().loc to align decorations correctly
|
||||
let loc = (space.element_location(win).unwrap_or((0, 0).into())
|
||||
- win.geometry().loc)
|
||||
.to_physical(1);
|
||||
|
|
|
@ -249,6 +249,14 @@ impl WindowElement {
|
|||
self.with_state(|st| st.tags.first().and_then(|tag| tag.output(state)))
|
||||
}
|
||||
|
||||
/// RefCell Safety: This uses RefCells on both `self` and everything in `outputs`.
|
||||
pub fn is_on_active_tag<'a>(&self, outputs: impl IntoIterator<Item = &'a Output>) -> bool {
|
||||
let mut tags = outputs.into_iter().flat_map(|op| {
|
||||
op.with_state(|state| state.focused_tags().cloned().collect::<Vec<_>>())
|
||||
});
|
||||
self.with_state(|state| state.tags.iter().any(|tag| tags.any(|tag2| tag == &tag2)))
|
||||
}
|
||||
|
||||
/// Returns `true` if the window element is [`Wayland`].
|
||||
///
|
||||
/// [`Wayland`]: WindowElement::Wayland
|
||||
|
|
Loading…
Add table
Reference in a new issue