[gtk: 1/2] imwayland: Fix get_preedit_string cursor position



commit 9576222b475129d3b178a1fac9b511976c9695b7
Author: xdavidwu <xdavidwuph gmail com>
Date:   Fri Jan 17 16:01:01 2020 +0800

    imwayland: Fix get_preedit_string cursor position
    
    GtkIMContext get_preedit_string should return cursor position counted
    in characters, but cursor_begin here is counted in bytes. This add the
    missing conversion.

 gtk/gtkimcontextwayland.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkimcontextwayland.c b/gtk/gtkimcontextwayland.c
index 3344a68cad..4fcc2f9a01 100644
--- a/gtk/gtkimcontextwayland.c
+++ b/gtk/gtkimcontextwayland.c
@@ -592,7 +592,8 @@ gtk_im_context_wayland_get_preedit_string (GtkIMContext   *context,
   if (str)
     *str = g_strdup (preedit_str);
   if (cursor_pos)
-    *cursor_pos = context_wayland->current_preedit.cursor_begin;
+    *cursor_pos = g_utf8_strlen (preedit_str,
+                                 context_wayland->current_preedit.cursor_begin);
 
   if (attrs)
     {


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