diff options
author | Andreas Kling <kling@serenityos.org> | 2020-05-21 17:26:09 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-05-21 17:26:09 +0200 |
commit | 4806cd122d3cebcd8808b2a7c3f37a83d1e193bf (patch) | |
tree | f326057924cb1fd0a1db470f896a75ba2e4c38ed /Libraries/LibGUI/Window.cpp | |
parent | 65d94a1e74259a23d189195a9d9d9c17988cf078 (diff) | |
download | serenity-4806cd122d3cebcd8808b2a7c3f37a83d1e193bf.zip |
LibGUI: Focus the first focusable widget added to a window
It feels really awkward if nothing is focused when opening a window.
Diffstat (limited to 'Libraries/LibGUI/Window.cpp')
-rw-r--r-- | Libraries/LibGUI/Window.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Libraries/LibGUI/Window.cpp b/Libraries/LibGUI/Window.cpp index c0607948e4..805c8353f0 100644 --- a/Libraries/LibGUI/Window.cpp +++ b/Libraries/LibGUI/Window.cpp @@ -761,7 +761,13 @@ void Window::set_size_increment(const Gfx::Size& size_increment) WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowBaseSizeAndSizeIncrement>(m_window_id, m_base_size, m_size_increment); } -void Window::did_remove_widget(Badge<Widget>, const Widget& widget) +void Window::did_add_widget(Badge<Widget>, Widget& widget) +{ + if (!m_focused_widget && widget.accepts_focus()) + set_focused_widget(&widget); +} + +void Window::did_remove_widget(Badge<Widget>, Widget& widget) { if (m_focused_widget == &widget) m_focused_widget = nullptr; |