[gnome-shell/wip/carlosg/input-focus-anchor: 2/2] inputMethod: Update to set_preedit_text() API change




commit b0187d42610ebb287c19ea974e47a0a07fe91127
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Jul 18 15:11:49 2022 +0200

    inputMethod: Update to set_preedit_text() API change
    
    Since IBus does not provide this information right away, we
    so far cannot do much about providing a truthful anchor position
    for the preedit text. But with the Mutter API in place it will
    be up to this object to do so in the future.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2384>

 js/misc/inputMethod.js | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/js/misc/inputMethod.js b/js/misc/inputMethod.js
index 8c3cd61aeb..856bf57aec 100644
--- a/js/misc/inputMethod.js
+++ b/js/misc/inputMethod.js
@@ -18,6 +18,7 @@ class InputMethod extends Clutter.InputMethod {
         this._currentFocus = null;
         this._preeditStr = '';
         this._preeditPos = 0;
+        this._preeditAnchor = 0;
         this._preeditVisible = false;
         this._hidePanelId = 0;
         this._ibus = IBus.Bus.new_async();
@@ -85,6 +86,7 @@ class InputMethod extends Clutter.InputMethod {
         this._purpose = 0;
         this._preeditStr = '';
         this._preeditPos = 0;
+        this._preeditAnchor = 0;
         this._preeditVisible = false;
     }
 
@@ -114,24 +116,30 @@ class InputMethod extends Clutter.InputMethod {
         if (preedit === '')
             preedit = null;
 
+        const anchor = pos;
         if (visible)
-            this.set_preedit_text(preedit, pos, mode);
+            this.set_preedit_text(preedit, pos, anchor, mode);
         else if (this._preeditVisible)
-            this.set_preedit_text(null, pos, mode);
+            this.set_preedit_text(null, pos, anchor, mode);
 
         this._preeditStr = preedit;
         this._preeditPos = pos;
+        this._preeditAnchor = anchor;
         this._preeditVisible = visible;
         this._preeditCommitMode = mode;
     }
 
     _onShowPreeditText() {
         this._preeditVisible = true;
-        this.set_preedit_text(this._preeditStr, this._preeditPos, this._preeditCommitMode);
+        this.set_preedit_text(
+            this._preeditStr, this._preeditPos, this._preeditAnchor,
+            this._preeditCommitMode);
     }
 
     _onHidePreeditText() {
-        this.set_preedit_text(null, this._preeditPos, this._preeditCommitMode);
+        this.set_preedit_text(
+            null, this._preeditPos, this._preeditAnchor,
+            this._preeditCommitMode);
         this._preeditVisible = false;
     }
 
@@ -169,7 +177,7 @@ class InputMethod extends Clutter.InputMethod {
 
         if (this._preeditStr && this._preeditVisible) {
             // Unset any preedit text
-            this.set_preedit_text(null, 0, this._preeditCommitMode);
+            this.set_preedit_text(null, 0, 0, this._preeditCommitMode);
             this._preeditStr = null;
         }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]