From 5f6745cad026e6c57d84fad0cb735f84891aaf6f Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 15 Feb 2018 12:20:51 +0100 Subject: [PATCH] keyboard: Shift key shouldn't latch the state unless long pressed Instead of latching all states, make shift unlatched by default, and only latched when making a long press on the key. When not latched, the keyboard will switch to the first level (alphabetic lowercase) after the first key press. Also, move the actual level switch to Key::pressed, so it feels more reactive on long press. https://gitlab.gnome.org/GNOME/gnome-shell/issues/46 --- js/ui/keyboard.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js index ea66b8375..37e86fdb7 100644 --- a/js/ui/keyboard.js +++ b/js/ui/keyboard.js @@ -499,6 +499,7 @@ var Keyboard = new Lang.Class({ this._enableKeyboard = false; // a11y settings value this._enabled = false; // enabled state (by setting or device type) + this._latched = false; // current level is latched this._a11yApplicationsSettings = new Gio.Settings({ schema_id: A11Y_APPLICATIONS_SCHEMA }); this._a11yApplicationsSettings.connect('changed', Lang.bind(this, this._syncEnabled)); @@ -787,6 +788,9 @@ var Keyboard = new Lang.Class({ this._keyboardController.keyvalRelease(keyval); button._keyvalPress = false; } + + if (!this._latched) + this._setActiveLayer(0); })); layout.appendKey(button.actor, button.keyButton.keyWidth); @@ -821,13 +825,16 @@ var Keyboard = new Lang.Class({ let actor = extraButton.keyButton; extraButton.connect('pressed', Lang.bind(this, function() { - if (keyval != null) + if (switchToLevel != null) { + this._setActiveLayer(switchToLevel); + // Shift only gets latched on long press + this._latched = (switchToLevel != 1); + } else if (keyval != null) { this._keyboardController.keyvalPress(keyval); + } })); extraButton.connect('released', Lang.bind(this, function() { - if (switchToLevel != null) - this._setActiveLayer(switchToLevel); - else if (keyval != null) + if (keyval != null) this._keyboardController.keyvalRelease(keyval); else if (action == 'hide') this.hide(); @@ -835,6 +842,12 @@ var Keyboard = new Lang.Class({ this._popupLanguageMenu(actor); })); + if (switchToLevel == 1) { + extraButton.connect('long-press', Lang.bind(this, function() { + this._latched = true; + })); + } + /* Fixup default keys based on the number of levels/keys */ if (key.label == '⇧' && numLevels == 3) { if (key.right) {