mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWeb: Filter input events by page_id in EventLoop
This commit is contained in:
committed by
Alexander Kalenik
parent
e6521d8ead
commit
a3984c4382
Notes:
github-actions[bot]
2025-12-11 08:03:23 +00:00
Author: https://github.com/pepperoni21 🔰 Commit: https://github.com/LadybirdBrowser/ladybird/commit/a3984c43828 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7085 Reviewed-by: https://github.com/kalenikaliaksandr ✅ Reviewed-by: https://github.com/konradekk
@@ -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();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user