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




commit bc6c7e4ef9c020d9b93afb1e95d77fed4cec895d
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 | 23 +++++------------------
 1 file changed, 5 insertions(+), 18 deletions(-)
---
diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js
index 639a742737..168b2aeda8 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;
-                }
-
                 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 != null)
-                    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]