From 73ea191a0592dea9011bc5e47be377a8acd11110 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 30 Oct 2020 11:34:19 +0100 Subject: [PATCH] LibGUI: TabWidget should not steal focus on programmatic tab switch This matches the behavior of GUI::StackWidget. --- Libraries/LibGUI/TabWidget.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Libraries/LibGUI/TabWidget.cpp b/Libraries/LibGUI/TabWidget.cpp index 7386505678..88d31ac1e1 100644 --- a/Libraries/LibGUI/TabWidget.cpp +++ b/Libraries/LibGUI/TabWidget.cpp @@ -79,12 +79,15 @@ void TabWidget::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(child_rect_for_size(size())); - m_active_widget->set_focus(true); + if (had_focus) + m_active_widget->set_focus(true); m_active_widget->set_visible(true); deferred_invoke([this](auto&) { if (on_change)