autosplit: better skip logic

This commit is contained in:
Alex Janka 2024-09-26 10:41:13 +10:00
parent 5e236b2d3d
commit d537999b8c

View file

@ -165,12 +165,17 @@ async fn autosplit(
) -> Res<()> {
if node.node_type == swayipc_async::NodeType::Con {
let (width, height) = (node.window_rect.width, node.window_rect.height);
if width == 0 || height == 0 {
// we don't want to split zero-sized windows, but containers are also zero-sized
// - so only skip if size is 0 and we have no children
if (width == 0 || height == 0) && node.focus.is_empty() {
return Ok(());
}
if tree
.find_as_ref(|n| n.focus.contains(&node.id))
.is_some_and(|parent| parent.node_type != swayipc_async::NodeType::Workspace)
.is_some_and(|parent| {
parent.layout != swayipc_async::NodeLayout::SplitH
&& parent.layout != swayipc_async::NodeLayout::SplitV
})
{
return Ok(());
}