[gtk: 1/2] gtktextviewaccessible: update cursor position after text suppression



commit a1f206b802a652bc495d479fb4b27b1f175182eb
Author: Samuel Thibault <samuel thibault ens-lyon org>
Date:   Wed Apr 4 18:18:29 2018 +0200

    gtktextviewaccessible: update cursor position after text suppression
    
    delete_range_cb is set to be called before the text suppression done by
    the gtktextlayout (otherwise it does not work properly). But at that
    point the cursor position is not yet up to date.  We thus need to move
    the accessibility cursor notification to after the actual text
    suppression, by using another callback.
    
    This fixes cursor position in brltty screen reading.
    
    (cherry picked from commit fa6994d0331a219e85dce01007b2d6f3f7fd43c9)

 gtk/a11y/gtktextviewaccessible.c | 40 +++++++++++++++++++++++++++-------------
 1 file changed, 27 insertions(+), 13 deletions(-)
---
diff --git a/gtk/a11y/gtktextviewaccessible.c b/gtk/a11y/gtktextviewaccessible.c
index 3d46ed1ba0..b6b5a657f2 100644
--- a/gtk/a11y/gtktextviewaccessible.c
+++ b/gtk/a11y/gtktextviewaccessible.c
@@ -39,19 +39,23 @@ struct _GtkTextViewAccessiblePrivate
   gint selection_bound;
 };
 
-static void       insert_text_cb       (GtkTextBuffer    *buffer,
-                                                        GtkTextIter      *arg1,
-                                                        gchar            *arg2,
-                                                        gint             arg3,
-                                                        gpointer         user_data);
-static void       delete_range_cb      (GtkTextBuffer    *buffer,
-                                                        GtkTextIter      *arg1,
-                                                        GtkTextIter      *arg2,
-                                                        gpointer         user_data);
-static void       mark_set_cb          (GtkTextBuffer    *buffer,
-                                                        GtkTextIter      *arg1,
-                                                        GtkTextMark      *arg2,
-                                                        gpointer         user_data);
+static void       insert_text_cb        (GtkTextBuffer    *buffer,
+                                                         GtkTextIter      *arg1,
+                                                         gchar            *arg2,
+                                                         gint             arg3,
+                                                         gpointer         user_data);
+static void       delete_range_cb       (GtkTextBuffer    *buffer,
+                                                         GtkTextIter      *arg1,
+                                                         GtkTextIter      *arg2,
+                                                         gpointer         user_data);
+static void       delete_range_after_cb (GtkTextBuffer    *buffer,
+                                                         GtkTextIter      *arg1,
+                                                         GtkTextIter      *arg2,
+                                                         gpointer         user_data);
+static void       mark_set_cb           (GtkTextBuffer    *buffer,
+                                                         GtkTextIter      *arg1,
+                                                         GtkTextMark      *arg2,
+                                                         gpointer         user_data);
 
 
 static void atk_editable_text_interface_init      (AtkEditableTextIface      *iface);
@@ -132,6 +136,7 @@ gtk_text_view_accessible_change_buffer (GtkTextViewAccessible *accessible,
     {
       g_signal_connect_after (new_buffer, "insert-text", G_CALLBACK (insert_text_cb), accessible);
       g_signal_connect (new_buffer, "delete-range", G_CALLBACK (delete_range_cb), accessible);
+      g_signal_connect_after (new_buffer, "delete-range", G_CALLBACK (delete_range_after_cb), accessible);
       g_signal_connect_after (new_buffer, "mark-set", G_CALLBACK (mark_set_cb), accessible);
 
       g_signal_emit_by_name (accessible,
@@ -1801,6 +1806,15 @@ delete_range_cb (GtkTextBuffer *buffer,
                          "text-changed::delete",
                          offset,
                          length);
+}
+
+static void
+delete_range_after_cb (GtkTextBuffer *buffer,
+                       GtkTextIter   *start,
+                       GtkTextIter   *end,
+                       gpointer       data)
+{
+  GtkTextViewAccessible *accessible = data;
 
   gtk_text_view_accessible_update_cursor (accessible, buffer);
 }


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