Avoid unnecessarily unwrapping stack_ref() after is_stack()

In a lot of cases, matching on `stack_ref()` also works.
This commit is contained in:
Ian Douglas Scott 2026-06-18 19:43:45 -07:00 committed by Ian Douglas Scott
parent 26ee83aaa7
commit f765696834
4 changed files with 20 additions and 30 deletions

View file

@ -1877,8 +1877,8 @@ impl TilingLayout {
if let Some(id) = id {
return match tree.get(&id).unwrap().data() {
Data::Mapped { mapped, .. } => {
if mapped.is_stack() {
mapped.stack_ref().unwrap().focus_stack();
if let Some(stack) = mapped.stack_ref() {
stack.focus_stack();
}
FocusResult::Some(mapped.clone().into())
}
@ -1986,11 +1986,11 @@ impl TilingLayout {
}))
}
Data::Mapped { mapped, .. } => {
if mapped.is_stack()
if let Some(stack) = mapped.stack_ref()
&& desc.stack_window.is_none()
&& replacement_id == &desc.node
{
mapped.stack_ref().unwrap().focus_stack();
stack.focus_stack();
}
FocusResult::Some(KeyboardFocusTarget::Element(mapped.clone()))
}
@ -2062,7 +2062,7 @@ impl TilingLayout {
});
}
Data::Mapped { mapped, .. } => {
if mapped.is_stack()
if let Some(stack) = mapped.stack_ref()
&& swap_desc
.as_ref()
.map(|desc| {
@ -2071,7 +2071,7 @@ impl TilingLayout {
})
.unwrap_or(false)
{
mapped.stack_ref().unwrap().focus_stack();
stack.focus_stack();
}
return FocusResult::Some(mapped.clone().into());
}