commit b50e5ed4d0fb9a8037f6301e17e9e95eeb49dd9c Author: Peng Wu Date: Wed May 13 19:01:03 2020 +0800 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 https://bugzilla.mozilla.org/show_bug.cgi?id=867433 https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/30 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() {