mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-07 19:57:45 +03: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:
parent
cf93c66e6e
commit
0b798a50dc
Notes:
sideshowbarker
2024-07-19 01:38:27 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/0b798a50dc8
@ -26,6 +26,7 @@
|
||||
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
#include <LibGUI/StackWidget.h>
|
||||
#include <LibGUI/Window.h>
|
||||
|
||||
namespace GUI {
|
||||
|
||||
@ -42,7 +43,7 @@ void StackWidget::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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user