From 6a0c67d5d22904de5f7524777ec47469dc33c3db Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Wed, 4 Sep 2024 21:13:38 -0400 Subject: [PATCH] UI/AppKit: Do not expose PUA key event code points to WebContent AppKit uses Private Use Area code points for a large collection of functional keys (arrows, home/end, etc.). Re-assign them to 0 to avoid tripping up WebContent's key handler. --- Ladybird/AppKit/UI/Event.mm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Ladybird/AppKit/UI/Event.mm b/Ladybird/AppKit/UI/Event.mm index 4812499189a..f119f587a5f 100644 --- a/Ladybird/AppKit/UI/Event.mm +++ b/Ladybird/AppKit/UI/Event.mm @@ -304,6 +304,10 @@ Web::KeyEvent ns_event_to_key_event(Web::KeyEvent::Type type, NSEvent* event) // FIXME: WebContent should really support multi-code point key events. auto code_point = utf8_view.is_empty() ? 0u : *utf8_view.begin(); + // NSEvent assigns PUA code points to to functional keys, e.g. arrow keys. Do not propagate them. + if (code_point >= 0xE000 && code_point <= 0xF8FF) + code_point = 0; + return { type, key_code, modifiers, code_point, make(event) }; }