[gnome-shell/wip/carlosg/im-update-preedit-with-mode] inputMethod: Use update-preedit-with-mode signal
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/carlosg/im-update-preedit-with-mode] inputMethod: Use update-preedit-with-mode signal
- Date: Tue, 27 Jul 2021 15:01:23 +0000 (UTC)
commit 88b69219fa08cfef25f1dcf86e6cb538c915d8ae
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Jul 27 16:52:32 2021 +0200
inputMethod: Use update-preedit-with-mode signal
This signal announces the preferred commit mode of the preedit text when
the input context is reset. Keep this mode around, and ensure to honor this
mode (e.g. maybe commit the preedit string) whenever the input method would
be reset.
js/misc/inputMethod.js | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
---
diff --git a/js/misc/inputMethod.js b/js/misc/inputMethod.js
index 0bc1462ef1..96fc734381 100644
--- a/js/misc/inputMethod.js
+++ b/js/misc/inputMethod.js
@@ -62,9 +62,10 @@ class InputMethod extends Clutter.InputMethod {
return;
}
+ this._context.set_client_commit_preedit(true);
this._context.connect('commit-text', this._onCommitText.bind(this));
this._context.connect('delete-surrounding-text', this._onDeleteSurroundingText.bind(this));
- this._context.connect('update-preedit-text', this._onUpdatePreeditText.bind(this));
+ this._context.connect('update-preedit-text-with-mode', this._onUpdatePreeditText.bind(this));
this._context.connect('show-preedit-text', this._onShowPreeditText.bind(this));
this._context.connect('hide-preedit-text', this._onHidePreeditText.bind(this));
this._context.connect('forward-key-event', this._onForwardKeyEvent.bind(this));
@@ -105,7 +106,7 @@ class InputMethod extends Clutter.InputMethod {
}
}
- _onUpdatePreeditText(_context, text, pos, visible) {
+ _onUpdatePreeditText(_context, text, pos, visible, mode) {
if (text == null)
return;
@@ -119,6 +120,7 @@ class InputMethod extends Clutter.InputMethod {
this._preeditStr = preedit;
this._preeditPos = pos;
this._preeditVisible = visible;
+ this._preeditCommitMode = mode;
}
_onShowPreeditText() {
@@ -167,6 +169,7 @@ class InputMethod extends Clutter.InputMethod {
// Unset any preedit text
this.set_preedit_text(null, 0);
this._preeditStr = null;
+ this._preeditCommitMode = null;
}
this._hidePanelId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, HIDE_PANEL_TIME, () => {
@@ -177,16 +180,20 @@ class InputMethod extends Clutter.InputMethod {
}
vfunc_reset() {
- if (this._context) {
- this._context.reset();
- this._emitRequestSurrounding();
- }
+ if (this._preeditStr !== null) {
+ if (this._preeditCommitMode === IBus.PreeditFocusMode.COMMIT)
+ this.commit(this._preeditStr);
- if (this._preeditStr) {
// Unset any preedit text
this.set_preedit_text(null, 0);
this._preeditStr = null;
}
+
+ if (this._context) {
+ this._context.reset();
+ this._emitRequestSurrounding();
+ }
+
}
vfunc_set_cursor_location(rect) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]