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




commit 5381d4422de65064961e9053212213bb339dc177
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 | 31 ++++++++-----------------------
 1 file changed, 8 insertions(+), 23 deletions(-)
---
diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js
index f08ff8fd17..a5844e7e08 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();
@@ -1501,20 +1500,11 @@ var Keyboard = GObject.registerClass({
 
             button.connect('pressed', (actor, keyval, str) => {
                 if (!Main.inputMethod.currentFocus ||
-                    !this._keyboardController.commitString(str, true)) {
-                    if (keyval != 0) {
-                        this._keyboardController.keyvalPress(keyval);
-                        button._keyvalPress = true;
-                    }
-                }
+                    !this._keyboardController.commitString(str, true) &&
+                    keyval !== 0)
+                    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 +1551,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 +2112,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]