ibusManager: Add OSK completion mode

This mode changes the current IBus engine to ibus-typing-booster
under the rug (i.e. no changes in keyboard status menu) for any
XKB engine selected.

In order to make it useful for the currently selected language,
the typing-booster dictionary is changed to the current XKB
layout language. And since the OSK has its own emoji panel,
typing-boosters own emoji completion is disabled.

These changes only apply as long as the OSK panel is shown,
reverting to the original engine and typing-booster configuration
after it is hidden. This in theory also caters for users that
do have ibus-typing-booster enabled as an input source.

The final effect is text prediction for the language that is
being typed, according to the OSK layout, given that
ibus-typing-booster and the relevant hunspell dictionaries are
used.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2278>
This commit is contained in:
Carlos Garnacho
2022-04-22 13:28:02 +02:00
committed by Florian Müllner
parent 3c538fc7e2
commit b210b2de72
3 changed files with 79 additions and 1 deletions

View File

@ -1497,7 +1497,14 @@ var Keyboard = GObject.registerClass({
if (key.action !== 'modifier') {
button.connect('commit', (actor, keyval, str) => {
if (this._modifiers.length === 0 && str !== '' &&
keyval && this._oskCompletionEnabled) {
Main.inputMethod.handleVirtualKey(keyval);
return;
}
if (str === '' || !Main.inputMethod.currentFocus ||
(keyval && this._oskCompletionEnabled) ||
this._modifiers.size > 0 ||
!this._keyboardController.commitString(str, true)) {
if (keyval !== 0) {
@ -1865,6 +1872,8 @@ var Keyboard = GObject.registerClass({
return;
}
this._oskCompletionEnabled =
IBusManager.getIBusManager().setCompletionEnabled(true);
this._clearKeyboardRestTimer();
if (immediate) {
@ -1899,6 +1908,8 @@ var Keyboard = GObject.registerClass({
if (!this._keyboardVisible)
return;
IBusManager.getIBusManager().setCompletionEnabled(false);
this._oskCompletionEnabled = false;
this._clearKeyboardRestTimer();
if (immediate) {