summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI
diff options
context:
space:
mode:
authorLucas CHOLLET <lucas.chollet@free.fr>2023-03-08 18:31:53 -0500
committerJelle Raaijmakers <jelle@gmta.nl>2023-03-25 21:42:53 +0100
commitbaac824ee3b49608549671aec91e5c78961c19af (patch)
tree2a884ff3ef819f64727da931d80b360258e9cbdb /Userland/Libraries/LibGUI
parent0b14ef134d411ccc01a8c70d62f8bdf331892b16 (diff)
downloadserenity-baac824ee3b49608549671aec91e5c78961c19af.zip
LibGUI: Make `propagate_shortcuts` handle different level of propagation
First, this patch renames the function `propagate_shortcuts_up_to_application` to `propagate_shortcuts`. Handling those levels, will allow us to differentiate shortcuts at `Window` level and `Application` level. Which will be convenient to handle dialog-specific shortcuts.
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r--Userland/Libraries/LibGUI/Window.cpp8
-rw-r--r--Userland/Libraries/LibGUI/Window.h7
2 files changed, 10 insertions, 5 deletions
diff --git a/Userland/Libraries/LibGUI/Window.cpp b/Userland/Libraries/LibGUI/Window.cpp
index 519c6e54ee..bdbcd951b8 100644
--- a/Userland/Libraries/LibGUI/Window.cpp
+++ b/Userland/Libraries/LibGUI/Window.cpp
@@ -479,7 +479,7 @@ void Window::handle_multi_paint_event(MultiPaintEvent& event)
ConnectionToWindowServer::the().async_did_finish_painting(m_window_id, rects);
}
-void Window::propagate_shortcuts_up_to_application(KeyEvent& event, Widget* widget)
+void Window::propagate_shortcuts(KeyEvent& event, Widget* widget, ShortcutPropagationBoundary boundary)
{
VERIFY(event.type() == Event::KeyDown);
auto shortcut = Shortcut(event.modifiers(), event.key());
@@ -497,9 +497,9 @@ void Window::propagate_shortcuts_up_to_application(KeyEvent& event, Widget* widg
} while (widget);
}
- if (!action)
+ if (!action && boundary >= ShortcutPropagationBoundary::Window)
action = action_for_shortcut(shortcut);
- if (!action)
+ if (!action && boundary >= ShortcutPropagationBoundary::Application)
action = Application::the()->action_for_shortcut(shortcut);
if (action) {
@@ -533,7 +533,7 @@ void Window::handle_key_event(KeyEvent& event)
// Only process shortcuts if this is a keydown event.
if (event.type() == Event::KeyDown)
- propagate_shortcuts_up_to_application(event, nullptr);
+ propagate_shortcuts(event, nullptr, PropagationLimit::Application);
}
void Window::handle_resize_event(ResizeEvent& event)
diff --git a/Userland/Libraries/LibGUI/Window.h b/Userland/Libraries/LibGUI/Window.h
index 335f9dd0d1..41670a9753 100644
--- a/Userland/Libraries/LibGUI/Window.h
+++ b/Userland/Libraries/LibGUI/Window.h
@@ -229,7 +229,12 @@ public:
void set_always_on_top(bool always_on_top = true);
- void propagate_shortcuts_up_to_application(KeyEvent& event, Widget* widget);
+ enum class ShortcutPropagationBoundary {
+ Window,
+ Application,
+ };
+
+ void propagate_shortcuts(KeyEvent& event, Widget* widget, ShortcutPropagationBoundary = ShortcutPropagationBoundary::Application);
protected:
Window(Core::Object* parent = nullptr);