[gtk+] textview: Avoid relocating adjustments on ::size-allocate while these are animating



commit 9d7f1caca7073cdf4af3bd85b24dbe0209abdde2
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Jul 21 21:16:32 2014 +0200

    textview: Avoid relocating adjustments on ::size-allocate while these are animating
    
    An animation may be scheduled while the textview content changed in size, so the resize
    queued would just unset the animation and set the adjusments with a current value,
    defeating gtk_text_view_scroll_to_iter(). In this case, just avoid the adjustment change,
    as there is a target value on the way.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=733406

 gtk/gtkadjustment.c        |    6 ++++++
 gtk/gtkadjustmentprivate.h |    2 ++
 gtk/gtktextview.c          |    6 ++++--
 3 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkadjustment.c b/gtk/gtkadjustment.c
index 74541a8..88a02a5 100644
--- a/gtk/gtkadjustment.c
+++ b/gtk/gtkadjustment.c
@@ -1017,3 +1017,9 @@ gtk_adjustment_get_animation_duration (GtkAdjustment *adjustment)
 {
   return adjustment->priv->duration;
 }
+
+gboolean
+gtk_adjustment_is_animating (GtkAdjustment *adjustment)
+{
+  return adjustment->priv->tick_id != 0;
+}
diff --git a/gtk/gtkadjustmentprivate.h b/gtk/gtkadjustmentprivate.h
index 3d9ba4c..c088444 100644
--- a/gtk/gtkadjustmentprivate.h
+++ b/gtk/gtkadjustmentprivate.h
@@ -32,6 +32,8 @@ void gtk_adjustment_animate_to_value (GtkAdjustment *adjustment,
                                       gdouble        value);
 gdouble gtk_adjustment_get_target_value (GtkAdjustment *adjustment);
 
+gboolean gtk_adjustment_is_animating (GtkAdjustment *adjustment);
+
 G_END_DECLS
 
 
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 1a01582..4283f24 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -3887,8 +3887,10 @@ gtk_text_view_size_allocate (GtkWidget *widget,
   gtk_text_view_allocate_children (text_view);
 
   /* Update adjustments */
-  gtk_text_view_set_hadjustment_values (text_view);
-  gtk_text_view_set_vadjustment_values (text_view);
+  if (!gtk_adjustment_is_animating (priv->hadjustment))
+    gtk_text_view_set_hadjustment_values (text_view);
+  if (!gtk_adjustment_is_animating (priv->vadjustment))
+    gtk_text_view_set_vadjustment_values (text_view);
 
   /* The GTK resize loop processes all the pending exposes right
    * after doing the resize stuff, so the idle sizer won't have a


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