summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-09-18 18:02:06 +0200
committerAndreas Kling <kling@serenityos.org>2020-09-18 21:29:01 +0200
commit9b893037670e16bd0b51b8cb7f4e0d30bb710413 (patch)
treec5d7f34dfd5e5917727db21817463a4aee174d3e /Libraries
parent65b246aaf4c297b1eec295db7126872fdbae5a3f (diff)
downloadserenity-9b893037670e16bd0b51b8cb7f4e0d30bb710413.zip
LibGUI: StackWidget should not steal focus when switching active child
Only focus the new active child if the old one had focus previously.
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibGUI/StackWidget.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/Libraries/LibGUI/StackWidget.cpp b/Libraries/LibGUI/StackWidget.cpp
index eaaf05dfa1..c7baf99d69 100644
--- a/Libraries/LibGUI/StackWidget.cpp
+++ b/Libraries/LibGUI/StackWidget.cpp
@@ -42,12 +42,15 @@ void StackWidget::set_active_widget(Widget* widget)
if (widget == m_active_widget)
return;
+ bool had_focus = is_focused() || (m_active_widget && m_active_widget->is_focused());
+
if (m_active_widget)
m_active_widget->set_visible(false);
m_active_widget = widget;
if (m_active_widget) {
m_active_widget->set_relative_rect(rect());
- m_active_widget->set_focus(true);
+ if (had_focus)
+ m_active_widget->set_focus(true);
m_active_widget->set_visible(true);
}
if (on_active_widget_change)