[gtk/preedit-selection-fix: 3/8] imwayland: Pass anchor with surrounding




commit 35fceca157fdc6f49ace15db31a78cf779a9112f
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Mar 4 13:30:55 2021 -0500

    imwayland: Pass anchor with surrounding
    
    This was missing in the initial implementation since
    GtkIMContext did not have it in its api, but it was
    added now, so we can send the information.

 gtk/gtkimcontextwayland.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkimcontextwayland.c b/gtk/gtkimcontextwayland.c
index 0bee5162d9..b380a8a150 100644
--- a/gtk/gtkimcontextwayland.c
+++ b/gtk/gtkimcontextwayland.c
@@ -909,7 +909,8 @@ static void
 gtk_im_context_wayland_set_surrounding (GtkIMContext *context,
                                         const char   *text,
                                         int           len,
-                                        int           cursor_index)
+                                        int           cursor_index,
+                                        int           selection_bound)
 {
   GtkIMContextWayland *context_wayland;
 
@@ -918,8 +919,7 @@ gtk_im_context_wayland_set_surrounding (GtkIMContext *context,
   g_free (context_wayland->surrounding.text);
   context_wayland->surrounding.text = g_strndup (text, len);
   context_wayland->surrounding.cursor_idx = cursor_index;
-  /* Anchor is not exposed via the set_surrounding interface, emulating. */
-  context_wayland->surrounding.anchor_idx = cursor_index;
+  context_wayland->surrounding.anchor_idx = selection_bound;
 
   notify_surrounding_text (context_wayland);
   /* State changes coming from reset don't have any other opportunity to get
@@ -932,7 +932,8 @@ gtk_im_context_wayland_set_surrounding (GtkIMContext *context,
 static gboolean
 gtk_im_context_wayland_get_surrounding (GtkIMContext  *context,
                                         char         **text,
-                                        int           *cursor_index)
+                                        int           *cursor_index,
+                                        int           *selection_bound)
 {
   GtkIMContextWayland *context_wayland;
 
@@ -943,6 +944,7 @@ gtk_im_context_wayland_get_surrounding (GtkIMContext  *context,
 
   *text = context_wayland->surrounding.text;
   *cursor_index = context_wayland->surrounding.cursor_idx;
+  *selection_bound = context_wayland->surrounding.anchor_idx;
   return TRUE;
 }
 
@@ -962,8 +964,8 @@ gtk_im_context_wayland_class_init (GtkIMContextWaylandClass *klass)
   im_context_class->reset = gtk_im_context_wayland_reset;
   im_context_class->set_cursor_location = gtk_im_context_wayland_set_cursor_location;
   im_context_class->set_use_preedit = gtk_im_context_wayland_set_use_preedit;
-  im_context_class->set_surrounding = gtk_im_context_wayland_set_surrounding;
-  im_context_class->get_surrounding = gtk_im_context_wayland_get_surrounding;
+  im_context_class->set_surrounding_with_selection = gtk_im_context_wayland_set_surrounding;
+  im_context_class->get_surrounding_with_selection = gtk_im_context_wayland_get_surrounding;
 }
 
 static void


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