From 567b9c815f4286180f37c53fd43f03175a808d8e Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Wed, 13 May 2020 19:01:03 +0800 Subject: [PATCH] inputMethod: Support ibus update_preedit_string_with_mode feature This patch switch to use ibus_engine_update_preedit_text_with_mode function. The ibus-gtk3 module already use this feature to address Firefox double commit issue. But gnome-shell switches to use wayland input method module, this patch plan to use this feature for wayland input method module, too. https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1398 --- js/misc/inputMethod.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/js/misc/inputMethod.js b/js/misc/inputMethod.js index 0bc1462ef..eb110f8cd 100644 --- a/js/misc/inputMethod.js +++ b/js/misc/inputMethod.js @@ -19,6 +19,7 @@ class InputMethod extends Clutter.InputMethod { this._preeditStr = ''; this._preeditPos = 0; this._preeditVisible = false; + this._preeditMode = 0; this._hidePanelId = 0; this._ibus = IBus.Bus.new_async(); this._ibus.connect('connected', this._onConnected.bind(this)); @@ -62,9 +63,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._onUpdatePreeditTextWithMode.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,20 +107,21 @@ class InputMethod extends Clutter.InputMethod { } } - _onUpdatePreeditText(_context, text, pos, visible) { + _onUpdatePreeditTextWithMode(_context, text, pos, visible, mode) { if (text == null) return; let preedit = text.get_text(); if (visible) - this.set_preedit_text(preedit, pos); + this.set_preedit_text_with_mode(preedit, pos, mode); else if (this._preeditVisible) - this.set_preedit_text(null, pos); + this.set_preedit_text_with_mode(null, pos, mode); this._preeditStr = preedit; this._preeditPos = pos; this._preeditVisible = visible; + this._preeditMode = mode; } _onShowPreeditText() { -- 2.26.2