fix: the logic for resize direction in tiling mode

This commit is contained in:
Hojjat 2026-09-22 18:50:34 -06:00 • committed by Victoria Brekenfeld
parent e5010c23c9
commit 9f746ea3ff

View file

@ -3271,12 +3271,34 @@ impl TilingLayout {
} }
} }
let (_, inner) = self.gaps();
let mut result = None; let mut result = None;
let mut fork = None;
let mut lookup = Some(root.clone()); let mut lookup = Some(root.clone());
while let Some(node) = lookup { while let Some(node) = lookup {
let data = tree.get(&node).unwrap().data(); let data = tree.get(&node).unwrap().data();
if data.geometry().contains(location) { if data.geometry().contains(location) {
result = Some(node.clone()); result = Some(node.clone());
if let Data::Group {
orientation,
sizes,
last_geometry,
..
} = data
{
let (pos, mut split) = match orientation {
Orientation::Vertical => (location.x, last_geometry.loc.x),
Orientation::Horizontal => (location.y, last_geometry.loc.y),
};
for (idx, size) in
sizes.iter().take(sizes.len().saturating_sub(1)).enumerate()
{
split += size;
if (pos - split).abs() <= inner / 2 {
fork = Some((node.clone(), idx));
}
}
}
} }
lookup = None; lookup = None;
@ -3323,25 +3345,16 @@ impl TilingLayout {
) )
}) })
} }
Some(( Some((_, Data::Group { .. })) => {
id, let (id, idx) = fork?;
Data::Group { let Data::Group {
orientation, orientation,
last_geometry, last_geometry,
.. ..
}, } = tree.get(&id).unwrap().data().clone()
)) => { else {
let idx = tree unreachable!()
.children(&id) };
.unwrap()
.position(|node| {
let data = node.data();
match orientation {
Orientation::Vertical => location.x < data.geometry().loc.x,
Orientation::Horizontal => location.y < data.geometry().loc.y,
}
})
.and_then(|x| x.checked_sub(1))?;
Some(( Some((
ResizeForkTarget { ResizeForkTarget {
node: id.clone(), node: id.clone(),