summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-10-30 19:08:21 +0100
committerAndreas Kling <kling@serenityos.org>2020-10-30 19:17:09 +0100
commitdee639f19b00016c9562e0f67cb4be9287c9283a (patch)
tree9f25589104f271e1b2f95dfcfac9874c4f602714
parentb0cdb6b07410e7f99ab33d339c58f3c7ad1f0240 (diff)
downloadserenity-dee639f19b00016c9562e0f67cb4be9287c9283a.zip
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.
-rw-r--r--Libraries/LibGUI/StackWidget.cpp2
-rw-r--r--Libraries/LibGUI/TabWidget.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/Libraries/LibGUI/StackWidget.cpp b/Libraries/LibGUI/StackWidget.cpp
index 1f06eed24e..8af53e00a9 100644
--- a/Libraries/LibGUI/StackWidget.cpp
+++ b/Libraries/LibGUI/StackWidget.cpp
@@ -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);
diff --git a/Libraries/LibGUI/TabWidget.cpp b/Libraries/LibGUI/TabWidget.cpp
index e329f9a2ac..69d8914f97 100644
--- a/Libraries/LibGUI/TabWidget.cpp
+++ b/Libraries/LibGUI/TabWidget.cpp
@@ -93,7 +93,7 @@ void TabWidget::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);