inputMethod: Add signal/getter for surrounding text updates

We need to keep track of those at places, add a signal and getter
so that this information can be accessed from the OSK.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2278>
This commit is contained in:
Carlos Garnacho 2022-04-20 23:16:38 +02:00 committed by Florian Müllner
parent 2920738d23
commit 482e62cb75

View File

@ -10,8 +10,11 @@ Gio._promisify(IBus.Bus.prototype,
var HIDE_PANEL_TIME = 50; var HIDE_PANEL_TIME = 50;
var InputMethod = GObject.registerClass( var InputMethod = GObject.registerClass({
class InputMethod extends Clutter.InputMethod { Signals: {
'surrounding-text-set': {},
},
}, class InputMethod extends Clutter.InputMethod {
_init() { _init() {
super._init(); super._init();
this._hints = 0; this._hints = 0;
@ -202,6 +205,8 @@ class InputMethod extends Clutter.InputMethod {
this._emitRequestSurrounding(); this._emitRequestSurrounding();
} }
this._surroundingText = null;
this._surroundingTextCursor = null;
this._preeditStr = null; this._preeditStr = null;
} }
@ -214,6 +219,10 @@ class InputMethod extends Clutter.InputMethod {
} }
vfunc_set_surrounding(text, cursor, anchor) { vfunc_set_surrounding(text, cursor, anchor) {
this._surroundingText = text;
this._surroundingTextCursor = cursor;
this.emit('surrounding-text-set');
if (!this._context || !text) if (!this._context || !text)
return; return;
@ -298,4 +307,8 @@ class InputMethod extends Clutter.InputMethod {
}); });
return true; return true;
} }
getSurroundingText() {
return [this._surroundingText, this._surroundingTextCursor];
}
}); });