LibGUI: Improve TabWidget+StackWidget focus behavior further

When setting a new active widget, transfer focus if it's anywhere in
the old active widget's tree, not just at the immediate child.
This commit is contained in:
Andreas Kling 2020-10-30 19:08:21 +01:00
commit dee639f19b
Notes: sideshowbarker 2024-07-19 01:38:07 +09:00
2 changed files with 2 additions and 2 deletions

View file

@ -43,7 +43,7 @@ void StackWidget::set_active_widget(Widget* widget)
if (widget == m_active_widget)
return;
bool active_widget_had_focus = m_active_widget && window() && window()->focused_widget() == m_active_widget;
bool active_widget_had_focus = m_active_widget && window() && (window()->focused_widget() == m_active_widget || m_active_widget->is_ancestor_of(*window()->focused_widget()));
if (m_active_widget)
m_active_widget->set_visible(false);