From 18f288bb51704862ec3beb75fca321657fbb9e6a Mon Sep 17 00:00:00 2001 From: Sebastian Keller Date: Wed, 8 Nov 2023 10:46:52 +0100 Subject: [PATCH] keyboard: Fix backspace not getting released after deleting preedit When deleting is toggled while a preedit string is present, this causes _toggleDelete() to use keyvalPress(). After the entire preedit string has been deleted, _toggleDelete() will no longer hit the code path that would call keyvalRelease() due to hasPreedit() now being false. Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7171 Part-of: (cherry picked from commit 4722dd0d320567dadcffef498b0a811084df9244) --- js/ui/keyboard.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js index 9b8a6adbb..3f24af7a6 100644 --- a/js/ui/keyboard.js +++ b/js/ui/keyboard.js @@ -1635,15 +1635,20 @@ var Keyboard = GObject.registerClass({ this._deleteEnabled = enabled; this._timesDeleted = 0; - if (!Main.inputMethod.currentFocus || - Main.inputMethod.hasPreedit() || - Main.inputMethod.terminalMode) { - /* If there is no IM focus or are in the middle of preedit, - * fallback to keypresses */ - if (enabled) - this._keyboardController.keyvalPress(Clutter.KEY_BackSpace); - else - this._keyboardController.keyvalRelease(Clutter.KEY_BackSpace); + /* If there is no IM focus or are in the middle of preedit, fallback to + * keypresses */ + if (enabled && + (!Main.inputMethod.currentFocus || + Main.inputMethod.hasPreedit() || + Main.inputMethod.terminalMode)) { + this._keyboardController.keyvalPress(Clutter.KEY_BackSpace); + this._backspacePressed = true; + return; + } + + if (!enabled && this._backspacePressed) { + this._keyboardController.keyvalRelease(Clutter.KEY_BackSpace); + delete this._backspacePressed; return; }