keyboard: Add 'delete' OSK key action

This action will replace CLUTTER_KEY_Backspace emission for
the OSK backspace key. Following the available mockups, implement
different modes of operation:

- Single tap deletes a single character
- Long tap starts deleting characters one by one
- Longer tap switches to word-by-word deletion

This is made possible via the input method surrounding text,
inspecting the string to look the previous char/word position
backwards, and relies on IM focus providing enough context.

Since deleting text and getting surrounding text are both
async operations, we make one happen after the other, until
the button is released.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2278>
This commit is contained in:
Carlos Garnacho
2022-04-20 23:18:27 +02:00
committed by Florian Müllner
parent 482e62cb75
commit fce376939f
2 changed files with 102 additions and 0 deletions

View File

@ -311,4 +311,8 @@ var InputMethod = GObject.registerClass({
getSurroundingText() {
return [this._surroundingText, this._surroundingTextCursor];
}
hasPreedit() {
return this._preeditVisible && this._preeditStr !== '' && this._preeditStr !== null;
}
});