backends/native: Translate keycodes with xkb_key_state_get_one_sym()

There's two aspects from its documentation
(https://xkbcommon.org/doc/current/group__state.html#gae56031a8c1d48e7802da32f5f39f5738)
affecting us here:

1. "This function is similar to xkb_state_key_get_syms(), but intended for
    users which cannot or do not want to handle the case where multiple
    keysyms are returned (in which case this function is preferred)."

   We are indeed in that field, and have been for a long time.

2. "This function performs Capitalization Keysym Transformations."

   This is unlike the xkb_key_get_syms() function that we use, and
   convenient here for parity with X11 since it behaves exactly that
   way.

Fixes cases where the keysym for some keys is not properly capitalized
when caps lock is toggled, due to the output of capslock+key being
different from shift+key. An example of this is 'é' in french(azerty)
layout (bound to the '2' key). Even though shift+2 outputs '2',
capslock+é should output 'É'.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3058
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3306>
This commit is contained in:
Carlos Garnacho 2023-09-29 13:14:14 +02:00
parent b567256873
commit 6fe1b3145f

View File

@ -50,7 +50,6 @@ meta_key_event_new_from_evdev (ClutterInputDevice *device,
{ {
ClutterEvent *event; ClutterEvent *event;
xkb_keysym_t sym; xkb_keysym_t sym;
const xkb_keysym_t *syms;
char buffer[8]; char buffer[8];
gunichar unicode_value; gunichar unicode_value;
ClutterModifierType modifiers; ClutterModifierType modifiers;
@ -62,11 +61,7 @@ meta_key_event_new_from_evdev (ClutterInputDevice *device,
* upwards by 8. */ * upwards by 8. */
key = meta_xkb_evdev_to_keycode (key); key = meta_xkb_evdev_to_keycode (key);
n = xkb_key_get_syms (xkb_state, key, &syms); sym = xkb_state_key_get_one_sym (xkb_state, key);
if (n == 1)
sym = syms[0];
else
sym = XKB_KEY_NoSymbol;
modifiers = xkb_state_serialize_mods (xkb_state, XKB_STATE_MODS_EFFECTIVE) | modifiers = xkb_state_serialize_mods (xkb_state, XKB_STATE_MODS_EFFECTIVE) |
button_state; button_state;