[gnome-shell/gnome-3-38] keyboard: Handle symbolic OSK key codes as explicitly invalid



commit cf9d73ed5d316093ad7284ce5df95bce51409f28
Author: Daniel van Vugt <daniel van vugt canonical com>
Date:   Fri Mar 12 14:45:19 2021 +0800

    keyboard: Handle symbolic OSK key codes as explicitly invalid
    
    `key` is an empty string in this case, causing `charCodeAt(0)` to return
    `NaN`, which when passed to `Clutter.unicode_to_keysym` now generates an
    error in gjs >= 1.67.3:
    
    ```
    JS ERROR: Error: Argument wc: value is out of range for uint32
    ```
    
    And the symbolic keys like Backspace, Enter and Caps Lock would have their
    presses ignored.
    
    Just skip the call to `charCodeAt` that will fail and allow
    `Clutter.unicode_to_keysym` to return its usual error flag.
    
    Fixes: https://bugs.launchpad.net/bugs/1918738
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1758>
    (cherry picked from commit 1f0e4b58ab1af96840475896e2fe9409468b5be0)

 js/ui/keyboard.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js
index cf3a210de3..e2574f0871 100644
--- a/js/ui/keyboard.js
+++ b/js/ui/keyboard.js
@@ -326,7 +326,7 @@ var Key = GObject.registerClass({
     }
 
     _getKeyval(key) {
-        let unicode = key.charCodeAt(0);
+        let unicode = key.length ? key.charCodeAt(0) : undefined;
         return Clutter.unicode_to_keysym(unicode);
     }
 


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