[gnome-shell/wip/carlosg/osk-updates: 13/33] keyboard: Trigger OSK level changes on button release




commit 3b81e0f8eb5bedbdf1ab56fcf3db37994f9779f3
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Apr 15 19:47:09 2022 +0200

    keyboard: Trigger OSK level changes on button release
    
    Keep it consistent with the rest of the actions. For long press
    handling (i.e. shift turning to caps lock), this also means the
    release action should be cancelled after any long press, to prevent
    both from taking effect at the same time.
    
    Prior to this commit, we used to switch level (and hide the button
    being pressed) on button press, which made its long press handler
    never get a paired release and end up triggering caps lock.
    Performing the action on release ensures the shift key button does
    not fall into this situation, making this issue moot.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2278>

 js/ui/keyboard.js | 29 ++++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)
---
diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js
index e7d4fc3ba9..dd5607a7a3 100644
--- a/js/ui/keyboard.js
+++ b/js/ui/keyboard.js
@@ -1501,21 +1501,21 @@ var Keyboard = GObject.registerClass({
                     this._setActiveLayer(0);
             });
             if (key.action !== null) {
-                button.connect('pressed', () => {
-                    if (key.action === 'levelSwitch') {
-                        this._setActiveLayer(key.level);
-                        this._setLatched (
-                            key.level === 1 &&
-                                key.iconName === 'keyboard-caps-lock-symbolic');
-                    }
-                });
                 button.connect('released', () => {
-                    if (key.action === 'hide')
+                    if (key.action === 'hide') {
                         this.close();
-                    else if (key.action === 'languageMenu')
+                    } else if (key.action === 'languageMenu') {
                         this._popupLanguageMenu(button);
-                    else if (key.action === 'emoji')
+                    } else if (key.action === 'emoji') {
                         this._toggleEmoji();
+                    } else if (!this._longPressed && key.action === 'levelSwitch') {
+                        this._setActiveLayer(key.level);
+                        this._setLatched(
+                            key.level === 1 &&
+                                key.iconName === 'keyboard-caps-lock-symbolic');
+                    }
+
+                    this._longPressed = false;
                 });
             }
 
@@ -1523,8 +1523,11 @@ var Keyboard = GObject.registerClass({
                 key.iconName === 'keyboard-shift-symbolic') {
                 layout.shiftKeys.push(button);
                 if (key.level === 1) {
-                    button.connect('long-press',
-                        () => this._setLatched(true));
+                    button.connect('long-press', () => {
+                        this._setActiveLayer(key.level);
+                        this._setLatched(true);
+                        this._longPressed = true;
+                    });
                 }
             }
 


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