LibWeb: Filter input events by page_id in EventLoop

This commit is contained in:
pepperoni21
2025-12-10 19:40:17 +08:00
committed by Alexander Kalenik
parent e6521d8ead
commit a3984c4382
Notes: github-actions[bot] 2025-12-11 08:03:23 +00:00

View File

@@ -267,8 +267,19 @@ void EventLoop::process_input_events() const
auto process_input_events_queue = [&](Page& page) {
auto& page_client = page.client();
auto& input_events_queue = page_client.input_event_queue();
// Process events only for this page, collecting others to re-enqueue
Queue<Web::QueuedInputEvent> events_for_other_pages;
while (!input_events_queue.is_empty()) {
auto event = input_events_queue.dequeue();
// Skip events that are not intended for this page
if (event.page_id != page_client.id()) {
events_for_other_pages.enqueue(move(event));
continue;
}
auto result = event.event.visit(
[&](KeyEvent const& key_event) {
switch (key_event.type) {
@@ -308,6 +319,11 @@ void EventLoop::process_input_events() const
page_client.report_finished_handling_input_event(event.page_id, result);
}
// Re-enqueue events for other pages
while (!events_for_other_pages.is_empty()) {
input_events_queue.enqueue(events_for_other_pages.dequeue());
}
page.handle_sdl_input_events();
};