[mutter/fix-key-repeat: 2/2] backends/x11: Fix key repeat of on-screen keyboard for second level keysyms




commit d3705e7496a6e4e7236d12c9f117ba3578880f80
Author: Ray Strode <rstrode redhat com>
Date:   Wed Oct 6 15:31:30 2021 -0400

    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.

 src/backends/x11/meta-keymap-x11.c               | 12 ++++++------
 src/backends/x11/meta-keymap-x11.h               |  6 +++---
 src/backends/x11/meta-virtual-input-device-x11.c |  4 ++--
 3 files changed, 11 insertions(+), 11 deletions(-)
---
diff --git a/src/backends/x11/meta-keymap-x11.c b/src/backends/x11/meta-keymap-x11.c
index bea8f4dd22..40032e1cde 100644
--- a/src/backends/x11/meta-keymap-x11.c
+++ b/src/backends/x11/meta-keymap-x11.c
@@ -856,9 +856,9 @@ meta_keymap_x11_release_keycode_if_needed (MetaKeymapX11 *keymap_x11,
 }
 
 void
-meta_keymap_x11_latch_modifiers (MetaKeymapX11 *keymap_x11,
-                                 uint32_t       level,
-                                 gboolean       enable)
+meta_keymap_x11_lock_modifiers (MetaKeymapX11 *keymap_x11,
+                                uint32_t       level,
+                                gboolean       enable)
 {
   uint32_t modifiers[] = {
     0,
@@ -878,9 +878,9 @@ meta_keymap_x11_latch_modifiers (MetaKeymapX11 *keymap_x11,
   else
     value = 0;
 
-  XkbLatchModifiers (meta_clutter_x11_get_default_display (),
-                     XkbUseCoreKbd, modifiers[level],
-                     value);
+  XkbLockModifiers (meta_clutter_x11_get_default_display (),
+                    XkbUseCoreKbd, modifiers[level],
+                    value);
 }
 
 static uint32_t
diff --git a/src/backends/x11/meta-keymap-x11.h b/src/backends/x11/meta-keymap-x11.h
index 67a5f8eb92..b83a6a81a4 100644
--- a/src/backends/x11/meta-keymap-x11.h
+++ b/src/backends/x11/meta-keymap-x11.h
@@ -44,9 +44,9 @@ 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,
-                                                   uint32_t          level,
-                                                   gboolean          enable);
+void     meta_keymap_x11_lock_modifiers          (MetaKeymapX11 *keymap_x11,
+                                                  uint32_t          level,
+                                                  gboolean          enable);
 gboolean meta_keymap_x11_reserve_keycode           (MetaKeymapX11 *keymap_x11,
                                                     guint             keyval,
                                                     guint            *keycode_out);
diff --git a/src/backends/x11/meta-virtual-input-device-x11.c 
b/src/backends/x11/meta-virtual-input-device-x11.c
index 54bb43ad1b..f6464fb918 100644
--- a/src/backends/x11/meta-virtual-input-device-x11.c
+++ b/src/backends/x11/meta-virtual-input-device-x11.c
@@ -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);
     }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]