From cae8b745cab97056d7fee9aa30053817f44f53ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Sun, 17 Nov 2024 19:16:58 +0100 Subject: [PATCH] keyboard: Don't press and release keyval if it's a modifier key Looks like we currently do the press-and-release dance for keys that specify both a keyval and the "modifier" action. So when pressing CTRL in the extended OSK, not only is the CTRL modifier set together with the next key pressed, but the actual CTRL keyval quickly gets pressed and released, similar to how we'd do it for the TAB key. This seems unintentional, as the press-and-release behavior should probably be specific to keys like TAB, and not apply to modifier keys, so limit that behavior to only keys without an action specified. Part-of: --- js/ui/keyboard.js | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js index a42c6ca87..4f41bc1bd 100644 --- a/js/ui/keyboard.js +++ b/js/ui/keyboard.js @@ -1491,28 +1491,6 @@ export const Keyboard = GObject.registerClass({ keyval: key.keyval, }, strings); - if (key.keyval) { - button.connect('keyval', (_actor, keyval) => { - this._keyboardController.keyvalPress(keyval); - this._keyboardController.keyvalRelease(keyval); - }); - } - - if (key.action !== 'modifier') { - button.connect('commit', (_actor, str) => { - this._keyboardController.commit(str, this._modifiers).then(() => { - this._disableAllModifiers(); - if (layout.mode === 'default' || - (layout.mode === 'latched' && !this._latched)) { - if (this._contentHint !== 0) - this._updateLevelFromHints(); - else - this._setActiveLevel('default'); - } - }).catch(console.error); - }); - } - if (key.action) { button.connect('released', () => { if (key.action === 'hide') { @@ -1535,6 +1513,24 @@ export const Keyboard = GObject.registerClass({ this._longPressed = false; }); + } else if (key.keyval) { + button.connect('keyval', (_actor, keyval) => { + this._keyboardController.keyvalPress(keyval); + this._keyboardController.keyvalRelease(keyval); + }); + } else { + button.connect('commit', (_actor, str) => { + this._keyboardController.commit(str, this._modifiers).then(() => { + this._disableAllModifiers(); + if (layout.mode === 'default' || + (layout.mode === 'latched' && !this._latched)) { + if (this._contentHint !== 0) + this._updateLevelFromHints(); + else + this._setActiveLevel('default'); + } + }).catch(console.error); + }); } if (key.action === 'levelSwitch' &&