summaryrefslogtreecommitdiff
path: root/LibGUI/GWindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'LibGUI/GWindow.cpp')
-rw-r--r--LibGUI/GWindow.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/LibGUI/GWindow.cpp b/LibGUI/GWindow.cpp
index 02c8c84a5c..3f1ca52c07 100644
--- a/LibGUI/GWindow.cpp
+++ b/LibGUI/GWindow.cpp
@@ -513,3 +513,27 @@ void GWindow::start_wm_resize()
message.wm.window_id = m_window_id;
GEventLoop::post_message_to_server(message);
}
+
+Vector<GWidget*> GWindow::focusable_widgets() const
+{
+ if (!m_main_widget)
+ return { };
+
+ Vector<GWidget*> collected_widgets;
+
+ Function<void(GWidget&)> collect_focusable_widgets = [&] (GWidget& widget) {
+ if (widget.accepts_focus())
+ collected_widgets.append(&widget);
+ for (auto& child : widget.children()) {
+ if (!child->is_widget())
+ continue;
+ auto& child_widget = *static_cast<GWidget*>(child);
+ if (!child_widget.is_visible())
+ continue;
+ collect_focusable_widgets(child_widget);
+ }
+ };
+
+ collect_focusable_widgets(*m_main_widget);
+ return collected_widgets;
+}