diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2022-11-21 16:07:47 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-11-26 00:44:49 +0100 |
commit | d94d60219c77dbeb1c27597a702d2b9a9f9967a7 (patch) | |
tree | a432cd7b1993b48f820a5748c4264c73ccf968c4 /Userland/Services/WebContent | |
parent | 2654bfead49ed900bc5fe0451487e5691d01980d (diff) | |
download | serenity-d94d60219c77dbeb1c27597a702d2b9a9f9967a7.zip |
LibWebView+WebContent: Propagate unconsumed input events out of OOPWV
Since 9e2bd9d261a8c0c1b5eeafde95ca310efc667204, the OOPWV has been
consuming all mouse and keyboard events, preventing action shortcuts
from working. So let's fix that. :^)
OOPWV now queues up input events, sending them one at a time to the
WebContent process and waiting for the new
`did_finish_handling_input_event(bool event_was_accepted) =|` IPC call
before sending the next one. If the event was not accepted, OOPWV
imitates the usual event bubbling: first passing the event to its
superclass, then to its parent widget, and finally propagating to any
Action shortcuts.
With this, shortcuts like Ctrl+I to open Browser's JS console work
again, except when a contenteditable field is selected. That's a
whole separate stack of yaks.
Co-authored-by: Zaggy1024 <zaggy1024@gmail.com>
Diffstat (limited to 'Userland/Services/WebContent')
-rw-r--r-- | Userland/Services/WebContent/ConnectionFromClient.cpp | 19 | ||||
-rw-r--r-- | Userland/Services/WebContent/ConnectionFromClient.h | 2 | ||||
-rw-r--r-- | Userland/Services/WebContent/WebContentClient.ipc | 1 |
3 files changed, 15 insertions, 7 deletions
diff --git a/Userland/Services/WebContent/ConnectionFromClient.cpp b/Userland/Services/WebContent/ConnectionFromClient.cpp index 7a939dbaf3..96802acd7d 100644 --- a/Userland/Services/WebContent/ConnectionFromClient.cpp +++ b/Userland/Services/WebContent/ConnectionFromClient.cpp @@ -157,37 +157,42 @@ void ConnectionFromClient::flush_pending_paint_requests() void ConnectionFromClient::mouse_down(Gfx::IntPoint const& position, unsigned int button, unsigned int buttons, unsigned int modifiers) { - page().handle_mousedown(position, button, buttons, modifiers); + report_finished_handling_input_event(page().handle_mousedown(position, button, buttons, modifiers)); } void ConnectionFromClient::mouse_move(Gfx::IntPoint const& position, [[maybe_unused]] unsigned int button, unsigned int buttons, unsigned int modifiers) { - page().handle_mousemove(position, buttons, modifiers); + report_finished_handling_input_event(page().handle_mousemove(position, buttons, modifiers)); } void ConnectionFromClient::mouse_up(Gfx::IntPoint const& position, unsigned int button, unsigned int buttons, unsigned int modifiers) { - page().handle_mouseup(position, button, buttons, modifiers); + report_finished_handling_input_event(page().handle_mouseup(position, button, buttons, modifiers)); } void ConnectionFromClient::mouse_wheel(Gfx::IntPoint const& position, unsigned int button, unsigned int buttons, unsigned int modifiers, i32 wheel_delta_x, i32 wheel_delta_y) { - page().handle_mousewheel(position, button, buttons, modifiers, wheel_delta_x, wheel_delta_y); + report_finished_handling_input_event(page().handle_mousewheel(position, button, buttons, modifiers, wheel_delta_x, wheel_delta_y)); } void ConnectionFromClient::doubleclick(Gfx::IntPoint const& position, unsigned int button, unsigned int buttons, unsigned int modifiers) { - page().handle_doubleclick(position, button, buttons, modifiers); + report_finished_handling_input_event(page().handle_doubleclick(position, button, buttons, modifiers)); } void ConnectionFromClient::key_down(i32 key, unsigned int modifiers, u32 code_point) { - page().handle_keydown((KeyCode)key, modifiers, code_point); + report_finished_handling_input_event(page().handle_keydown((KeyCode)key, modifiers, code_point)); } void ConnectionFromClient::key_up(i32 key, unsigned int modifiers, u32 code_point) { - page().handle_keyup((KeyCode)key, modifiers, code_point); + report_finished_handling_input_event(page().handle_keyup((KeyCode)key, modifiers, code_point)); +} + +void ConnectionFromClient::report_finished_handling_input_event(bool event_was_handled) +{ + async_did_finish_handling_input_event(event_was_handled); } void ConnectionFromClient::debug_request(String const& request, String const& argument) diff --git a/Userland/Services/WebContent/ConnectionFromClient.h b/Userland/Services/WebContent/ConnectionFromClient.h index d6194eebb0..7c4bb6fd38 100644 --- a/Userland/Services/WebContent/ConnectionFromClient.h +++ b/Userland/Services/WebContent/ConnectionFromClient.h @@ -98,6 +98,8 @@ private: void flush_pending_paint_requests(); + void report_finished_handling_input_event(bool event_was_handled); + NonnullOwnPtr<PageHost> m_page_host; struct PaintRequest { Gfx::IntRect content_rect; diff --git a/Userland/Services/WebContent/WebContentClient.ipc b/Userland/Services/WebContent/WebContentClient.ipc index 42e87a3217..c5c1e1df53 100644 --- a/Userland/Services/WebContent/WebContentClient.ipc +++ b/Userland/Services/WebContent/WebContentClient.ipc @@ -52,6 +52,7 @@ endpoint WebContentClient did_request_minimize_window() => (Gfx::IntRect window_rect) did_request_fullscreen_window() => (Gfx::IntRect window_rect) did_request_file(String path, i32 request_id) =| + did_finish_handling_input_event(bool event_was_accepted) =| did_output_js_console_message(i32 message_index) =| did_get_js_console_messages(i32 start_index, Vector<String> message_types, Vector<String> messages) =| |