tiling: Crop input region to tile

This commit is contained in:
Victoria Brekenfeld 2023-05-30 16:22:29 +02:00
parent 954843bc43
commit 9531b3798e
2 changed files with 37 additions and 25 deletions

View file

@ -2,8 +2,8 @@
use crate::{ use crate::{
backend::render::{ backend::render::{
element::AsGlowRenderer, IndicatorShader, Key, ACTIVE_GROUP_COLOR, FOCUS_INDICATOR_COLOR, element::AsGlowRenderer, IndicatorKey, IndicatorShader, ACTIVE_GROUP_COLOR,
GROUP_COLOR, FOCUS_INDICATOR_COLOR, GROUP_COLOR,
}, },
shell::{ shell::{
element::{window::CosmicWindowRenderElement, CosmicMapped, CosmicMappedRenderElement}, element::{window::CosmicWindowRenderElement, CosmicMapped, CosmicMappedRenderElement},
@ -1140,7 +1140,7 @@ impl TilingLayout {
.position(|id| id == &node_id) .position(|id| id == &node_id)
.unwrap(); .unwrap();
let idx = match edges { let idx = match edges {
x if x.intersects(ResizeEdge::TOP_LEFT) => node_idx - 1, x if x.intersects(ResizeEdge::TOP_LEFT) => node_idx.checked_sub(1)?,
_ => node_idx, _ => node_idx,
}; };
if idx > tree.get(&group_id).unwrap().data().len() { if idx > tree.get(&group_id).unwrap().data().len() {
@ -1384,7 +1384,9 @@ impl TilingLayout {
None None
} }
pub fn mapped(&self) -> impl Iterator<Item = (&Output, &CosmicMapped, Point<i32, Logical>)> { pub fn mapped(
&self,
) -> impl Iterator<Item = (&Output, &CosmicMapped, Rectangle<i32, Logical>)> {
self.queues self.queues
.iter() .iter()
.flat_map(|(output_data, queue)| { .flat_map(|(output_data, queue)| {
@ -1403,11 +1405,11 @@ impl TilingLayout {
mapped, mapped,
last_geometry, last_geometry,
.. ..
} => ( } => (&output_data.output, mapped, {
&output_data.output, let mut geo = last_geometry.clone();
mapped, geo.loc += output_data.location;
output_data.location + last_geometry.loc, geo
), }),
_ => unreachable!(), _ => unreachable!(),
}) })
.chain( .chain(
@ -1423,11 +1425,11 @@ impl TilingLayout {
mapped, mapped,
last_geometry, last_geometry,
.. ..
} => ( } => (&output_data.output, mapped, {
&output_data.output, let mut geo = last_geometry.clone();
mapped, geo.loc += output_data.location;
output_data.location + last_geometry.loc, geo
), }),
_ => unreachable!(), _ => unreachable!(),
}), }),
), ),
@ -1441,11 +1443,16 @@ impl TilingLayout {
pub fn windows( pub fn windows(
&self, &self,
) -> impl Iterator<Item = (Output, CosmicSurface, Point<i32, Logical>)> + '_ { ) -> impl Iterator<Item = (Output, CosmicSurface, Rectangle<i32, Logical>)> + '_ {
self.mapped().flat_map(|(output, mapped, loc)| { self.mapped().flat_map(|(output, mapped, geo)| {
mapped mapped.windows().map(move |(w, p)| {
.windows() (output.clone(), w, {
.map(move |(w, p)| (output.clone(), w, p + loc)) let mut geo = geo.clone();
geo.loc += p;
geo.size -= p.to_size();
geo
})
})
}) })
} }
@ -1748,7 +1755,7 @@ where
elements.push( elements.push(
IndicatorShader::element( IndicatorShader::element(
renderer, renderer,
Key::Group(Arc::downgrade(&alive)), IndicatorKey::Group(Arc::downgrade(&alive)),
geo, geo,
3, 3,
alpha, alpha,

View file

@ -202,11 +202,16 @@ impl Workspace {
.space .space
.element_under(location) .element_under(location)
.or_else(|| { .or_else(|| {
self.tiling_layer.mapped().find_map(|(_, mapped, loc)| { self.tiling_layer.mapped().find_map(|(_, mapped, geo)| {
let test_point = location - loc.to_f64() + mapped.geometry().loc.to_f64(); geo.contains(location.to_i32_round())
mapped .then(|| {
.is_in_input_region(&test_point) let test_point =
.then_some((mapped, loc - mapped.geometry().loc)) location - geo.loc.to_f64() + mapped.geometry().loc.to_f64();
mapped
.is_in_input_region(&test_point)
.then_some((mapped, geo.loc - mapped.geometry().loc))
})
.flatten()
}) })
}) })
} }