1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:08:12 +00:00

Userland: Actually use the correct character map index from KeyEvent

Instead of using a scan code, which for scan code set 2 will not
represent the expected character mapping index, we could just use
another variable in the KeyEvent structure that correctly points to the
character index.

This change is mostly relevant to the KeyboardMapper application, and
also to the WindowServer code, as both handle KeyEvents and need to
use the character mapping index in various situations.
This commit is contained in:
Liav A 2023-04-14 18:57:41 +03:00 committed by Andrew Kaster
parent b89cc81674
commit 60a96b3786
9 changed files with 41 additions and 32 deletions

View file

@ -180,13 +180,13 @@ static Action* action_for_shortcut(Window& window, Shortcut const& shortcut)
return nullptr;
}
void ConnectionToWindowServer::key_down(i32 window_id, u32 code_point, u32 key, u32 modifiers, u32 scancode)
void ConnectionToWindowServer::key_down(i32 window_id, u32 code_point, u32 key, u8 map_entry_index, u32 modifiers, u32 scancode)
{
auto* window = Window::from_window_id(window_id);
if (!window)
return;
auto key_event = make<KeyEvent>(Event::KeyDown, (KeyCode)key, modifiers, code_point, scancode);
auto key_event = make<KeyEvent>(Event::KeyDown, (KeyCode)key, map_entry_index, modifiers, code_point, scancode);
bool focused_widget_accepts_emoji_input = window->focused_widget() && window->focused_widget()->on_emoji_input;
if (!window->blocks_emoji_input() && focused_widget_accepts_emoji_input && (modifiers == (Mod_Ctrl | Mod_Alt)) && key == Key_Space) {
@ -201,13 +201,13 @@ void ConnectionToWindowServer::key_down(i32 window_id, u32 code_point, u32 key,
Core::EventLoop::current().post_event(*window, move(key_event));
}
void ConnectionToWindowServer::key_up(i32 window_id, u32 code_point, u32 key, u32 modifiers, u32 scancode)
void ConnectionToWindowServer::key_up(i32 window_id, u32 code_point, u32 key, u8 map_entry_index, u32 modifiers, u32 scancode)
{
auto* window = Window::from_window_id(window_id);
if (!window)
return;
auto key_event = make<KeyEvent>(Event::KeyUp, (KeyCode)key, modifiers, code_point, scancode);
auto key_event = make<KeyEvent>(Event::KeyUp, (KeyCode)key, map_entry_index, modifiers, code_point, scancode);
Core::EventLoop::current().post_event(*window, move(key_event));
}