Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fr+oss layout issues with KP period #102602

Merged
merged 1 commit into from
Feb 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions platform/linuxbsd/wayland/key_mapping_xkb.cpp
Original file line number Diff line number Diff line change
@@ -378,6 +378,7 @@ bool KeyMappingXKB::is_sym_numpad(xkb_keysym_t p_keysym) {
case XKB_KEY_KP_Divide:
case XKB_KEY_KP_Separator:
case XKB_KEY_KP_Decimal:
case XKB_KEY_KP_Delete:
case XKB_KEY_KP_0:
case XKB_KEY_KP_1:
case XKB_KEY_KP_2:
19 changes: 11 additions & 8 deletions platform/linuxbsd/wayland/wayland_thread.cpp
Original file line number Diff line number Diff line change
@@ -195,24 +195,27 @@ Vector<uint8_t> WaylandThread::_wp_primary_selection_offer_read(struct wl_displa
bool WaylandThread::_seat_state_configure_key_event(SeatState &p_ss, Ref<InputEventKey> p_event, xkb_keycode_t p_keycode, bool p_pressed) {
xkb_keysym_t shifted_sym = xkb_state_key_get_one_sym(p_ss.xkb_state, p_keycode);

xkb_keysym_t plain_sym = XKB_KEY_NoSymbol;
// NOTE: xkbcommon's API really encourages to apply the modifier state but we
// only want a "plain" symbol so that we can convert it into a godot keycode.
const xkb_keysym_t *syms = nullptr;
int num_sys = xkb_keymap_key_get_syms_by_level(p_ss.xkb_keymap, p_keycode, p_ss.current_layout_index, 0, &syms);
if (num_sys > 0 && syms) {
plain_sym = syms[0];
}

Key physical_keycode = KeyMappingXKB::get_scancode(p_keycode);
KeyLocation key_location = KeyMappingXKB::get_location(p_keycode);
uint32_t unicode = xkb_state_key_get_utf32(p_ss.xkb_state, p_keycode);

Key keycode = Key::NONE;

if (KeyMappingXKB::is_sym_numpad(shifted_sym)) {
if (KeyMappingXKB::is_sym_numpad(shifted_sym) || KeyMappingXKB::is_sym_numpad(plain_sym)) {
keycode = KeyMappingXKB::get_keycode(shifted_sym);
}

if (keycode == Key::NONE) {
// NOTE: xkbcommon's API really encourages to apply the modifier state but we
// only want a "plain" symbol so that we can convert it into a godot keycode.
const xkb_keysym_t *syms = nullptr;
int num_sys = xkb_keymap_key_get_syms_by_level(p_ss.xkb_keymap, p_keycode, p_ss.current_layout_index, 0, &syms);
if (num_sys > 0 && syms) {
keycode = KeyMappingXKB::get_keycode(syms[0]);
}
keycode = KeyMappingXKB::get_keycode(plain_sym);
}

if (keycode == Key::NONE) {
2 changes: 1 addition & 1 deletion platform/linuxbsd/x11/display_server_x11.cpp
Original file line number Diff line number Diff line change
@@ -3765,7 +3765,7 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event,
// keysym, so it works in all platforms the same.

Key keycode = Key::NONE;
if (KeyMappingX11::is_sym_numpad(keysym_unicode)) {
if (KeyMappingX11::is_sym_numpad(keysym_unicode) || KeyMappingX11::is_sym_numpad(keysym_keycode)) {
// Special case for numpad keys.
keycode = KeyMappingX11::get_keycode(keysym_unicode);
}
1 change: 1 addition & 0 deletions platform/linuxbsd/x11/key_mapping_x11.cpp
Original file line number Diff line number Diff line change
@@ -1138,6 +1138,7 @@ bool KeyMappingX11::is_sym_numpad(KeySym p_keysym) {
case XK_KP_Divide:
case XK_KP_Separator:
case XK_KP_Decimal:
case XK_KP_Delete:
case XK_KP_0:
case XK_KP_1:
case XK_KP_2: