backends/x11: Fix key repeat of on-screen keyboard for second level keysyms

Certains keys (such as ~ and |) are in the keyboard map behind the
second shift level. This means in order for them to be input, the
shift key needs to be held down by the user.

The GNOME Shell on-screen keyboard presents these keys separately on
a page of keys that has no shift key. Instead, it relies on mutter
to set a shift latch before the key event is emitted. A shift latch
is a virtual press of the shift key that automatically gets released
after the next key press (in our case the ~ or | key).

The problem is using a shift latch doesn't work very well in the face
of key repeat. The latch is automatically released after the first
press, and subsequent repeats of that press no longer have shift
latched to them.

This commit fixes the problem by using a shift lock instead of a shift
latch. A shift lock is never implicitly released, so it remains
in place for the duration of key repeat.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2045>
This commit is contained in:
Ray Strode 2021-10-06 15:31:30 -04:00 committed by Marge Bot
parent 8e1a125f70
commit 6060b6a240
3 changed files with 11 additions and 11 deletions

View File

@ -869,7 +869,7 @@ meta_keymap_x11_release_keycode_if_needed (MetaKeymapX11 *keymap_x11,
}
void
meta_keymap_x11_latch_modifiers (MetaKeymapX11 *keymap_x11,
meta_keymap_x11_lock_modifiers (MetaKeymapX11 *keymap_x11,
uint32_t level,
gboolean enable)
{
@ -891,7 +891,7 @@ meta_keymap_x11_latch_modifiers (MetaKeymapX11 *keymap_x11,
else
value = 0;
XkbLatchModifiers (meta_clutter_x11_get_default_display (),
XkbLockModifiers (meta_clutter_x11_get_default_display (),
XkbUseCoreKbd, modifiers[level],
value);
}

View File

@ -44,7 +44,7 @@ gboolean meta_keymap_x11_keycode_for_keyval (MetaKeymapX11 *keymap_x11,
guint keyval,
guint *keycode_out,
guint *level_out);
void meta_keymap_x11_latch_modifiers (MetaKeymapX11 *keymap_x11,
void meta_keymap_x11_lock_modifiers (MetaKeymapX11 *keymap_x11,
uint32_t level,
gboolean enable);
gboolean meta_keymap_x11_reserve_keycode (MetaKeymapX11 *keymap_x11,

View File

@ -186,7 +186,7 @@ meta_virtual_input_device_x11_notify_keyval (ClutterVirtualInputDevice *virtual_
if (!meta_keymap_x11_get_is_modifier (keymap, keycode) &&
key_state == CLUTTER_KEY_STATE_PRESSED)
meta_keymap_x11_latch_modifiers (keymap, level, TRUE);
meta_keymap_x11_lock_modifiers (keymap, level, TRUE);
XTestFakeKeyEvent (meta_clutter_x11_get_default_display (),
(KeyCode) keycode,
@ -196,7 +196,7 @@ meta_virtual_input_device_x11_notify_keyval (ClutterVirtualInputDevice *virtual_
if (key_state == CLUTTER_KEY_STATE_RELEASED)
{
if (!meta_keymap_x11_get_is_modifier (keymap, keycode))
meta_keymap_x11_latch_modifiers (keymap, level, FALSE);
meta_keymap_x11_lock_modifiers (keymap, level, FALSE);
meta_keymap_x11_release_keycode_if_needed (keymap, keycode);
}
}