[gnome-shell/drop-osk-key-repeat-feature: 2/2] keyboard: Emit key release right away




commit b11628629b04a57ed9dc860b24a47001c02f1d7a
Author: Ray Strode <rstrode redhat com>
Date:   Wed Oct 6 15:42:17 2021 -0400

    keyboard: Emit key release right away
    
    At the moment the on-screen keyboard doesn't emit the key release event
    until the user stops pushing the keyboard button with their pointer.
    
    This means if the user uses the pointer to hold the button down, it can
    generate repeat events for some keys.
    
    But this creates a bit of an inconsistency in behavior between keys that
    support multiple choices via long press and those that don't. The ones
    that support long press, don't repeat, instead they show the available
    choices.
    
    Furthermore, key repeat doesn't work for any of the keys with the
    wayland backend, since key repeat is a client side thing, and we just
    don't have it implemented for this path.
    
    Also, key repeat is repeating the wrong keys right now, even on X11, for
    keys that require a shift level (see
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2045 )
    
    Given key repeat is a dubious feature in an on-screen keyboard to begin
    with, and it's only implemented for one backend, and it's not even
    completely working on that backend, it's probably best to drop support.
    
    This commit changes the on-screen keyboard to always emit a key
    release immediately after each key press.

 js/ui/keyboard.js | 25 ++++++-------------------
 1 file changed, 6 insertions(+), 19 deletions(-)
---
diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js
index f08ff8fd17..fa385c6002 100644
--- a/js/ui/keyboard.js
+++ b/js/ui/keyboard.js
@@ -1400,8 +1400,7 @@ var Keyboard = GObject.registerClass({
 
         this._keypad = new Keypad();
         this._connectSignal(this._keypad, 'keyval', (_keypad, keyval) => {
-            this._keyboardController.keyvalPress(keyval);
-            this._keyboardController.keyvalRelease(keyval);
+            this._keyboardController.keyvalPressAndRelease(keyval);
         });
         this._aspectContainer.add_child(this._keypad);
         this._keypad.hide();
@@ -1503,18 +1502,11 @@ var Keyboard = GObject.registerClass({
                 if (!Main.inputMethod.currentFocus ||
                     !this._keyboardController.commitString(str, true)) {
                     if (keyval != 0) {
-                        this._keyboardController.keyvalPress(keyval);
-                        button._keyvalPress = true;
+                        this._keyboardController.keyvalPressAndRelease(keyval);
                     }
                 }
             });
-            button.connect('released', (actor, keyval, _str) => {
-                if (keyval != 0) {
-                    if (button._keyvalPress)
-                        this._keyboardController.keyvalRelease(keyval);
-                    button._keyvalPress = false;
-                }
-
+            button.connect('released', () => {
                 if (!this._latched)
                     this._setActiveLayer(0);
             });
@@ -1561,13 +1553,11 @@ var Keyboard = GObject.registerClass({
                     // Shift only gets latched on long press
                     this._latched = switchToLevel != 1;
                 } else if (keyval != null) {
-                    this._keyboardController.keyvalPress(keyval);
+                    this._keyboardController.keyvalPressAndRelease(keyval);
                 }
             });
             extraButton.connect('released', () => {
-                if (keyval)
-                    this._keyboardController.keyvalRelease(keyval);
-                else if (action === 'hide')
+                if (action === 'hide')
                     this.close();
                 else if (action === 'languageMenu')
                     this._popupLanguageMenu(actor);
@@ -2124,12 +2114,9 @@ var KeyboardController = class {
         return true;
     }
 
-    keyvalPress(keyval) {
+    keyvalPressAndRelease(keyval) {
         this._virtualDevice.notify_keyval(Clutter.get_current_event_time() * 1000,
                                           keyval, Clutter.KeyState.PRESSED);
-    }
-
-    keyvalRelease(keyval) {
         this._virtualDevice.notify_keyval(Clutter.get_current_event_time() * 1000,
                                           keyval, Clutter.KeyState.RELEASED);
     }


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