1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:28:11 +00:00

LibGUI: Make StackWidget/TabWidget preserve focus in inactive windows

This one is a bit sketchy. While a window is inactive, none of its
widgets are considered focused (Widget::is_focused() will return false)
but this caused programmatic changes of the active widget in a tab
or stack widget to fail focus propagation from old child to new child.

Work around this by checking against Window::focused_widget() directly
instead of asking Widget::is_focused().
This commit is contained in:
Andreas Kling 2020-10-30 16:25:52 +01:00
parent cf93c66e6e
commit 0b798a50dc
2 changed files with 4 additions and 2 deletions

View file

@ -29,6 +29,7 @@
#include <LibGUI/BoxLayout.h>
#include <LibGUI/Painter.h>
#include <LibGUI/TabWidget.h>
#include <LibGUI/Window.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/Font.h>
#include <LibGfx/Palette.h>
@ -81,7 +82,7 @@ void TabWidget::set_active_widget(Widget* widget)
if (widget == m_active_widget)
return;
bool active_widget_had_focus = m_active_widget && m_active_widget->is_focused();
bool active_widget_had_focus = m_active_widget && window() && window()->focused_widget() == m_active_widget;
if (m_active_widget)
m_active_widget->set_visible(false);