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); diff --git a/Userland/Libraries/LibVT/TerminalWidget.cpp b/Userland/Libraries/LibVT/TerminalWidget.cpp index 46c46f2b85..1a0468ab67 100644 --- a/Userland/Libraries/LibVT/TerminalWidget.cpp +++ b/Userland/Libraries/LibVT/TerminalWidget.cpp @@ -208,7 +208,7 @@ void TerminalWidget::keydown_event(GUI::KeyEvent& event) { // We specifically need to process shortcuts before input to the Terminal is done // since otherwise escape sequences will eat all our shortcuts for dinner. - window()->propagate_shortcuts_up_to_application(event, this); + window()->propagate_shortcuts(event, this); if (event.is_accepted()) return; diff --git a/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp b/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp index fe767b09b7..cee2b51ba1 100644 --- a/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp +++ b/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp @@ -751,7 +751,7 @@ void OutOfProcessWebView::notify_server_did_finish_handling_input_event(bool eve // NOTE: If other events can ever trigger shortcuts, propagate those here. if (!event.is_accepted() && event.type() == GUI::Event::Type::KeyDown) - window()->propagate_shortcuts_up_to_application(event, this); + window()->propagate_shortcuts(event, this); } }, [this](GUI::MouseEvent& event) {