[gtk+/adjustment-animation-fixes: 5/5] range: Avoid animations during slider drag



commit 3b658d9fa0766e30a7411d742366d26d8fe4722c
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Jul 8 15:35:18 2014 +0200

    range: Avoid animations during slider drag
    
    If the drag gesture gets a GtkGesture::updated signal, the user
    is directly interacting through pointer/touch with the range slider,
    animating the adjustment value change in this situation can produce
    perceived lag, so set the value immediately when this is happening.

 gtk/gtkrange.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index 5f309b9..84e79fa 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -156,6 +156,9 @@ struct _GtkRangePrivate
   /* Fill level */
   guint show_fill_level        : 1;
   guint restrict_to_fill_level : 1;
+
+  /* Whether dragging is ongoing */
+  guint in_drag                : 1;
 };
 
 
@@ -2909,6 +2912,7 @@ gtk_range_drag_gesture_update (GtkGestureDrag *gesture,
   gtk_gesture_drag_get_start_point (gesture, &start_x, &start_y);
   priv->mouse_x = start_x + offset_x;
   priv->mouse_y = start_y + offset_y;
+  priv->in_drag = TRUE;
 
   update_autoscroll_mode (range);
 
@@ -2922,6 +2926,7 @@ gtk_range_drag_gesture_end (GtkGestureDrag       *gesture,
                             gdouble               offset_y,
                             GtkRange             *range)
 {
+  range->priv->in_drag = FALSE;
   stop_scrolling (range);
 }
 
@@ -3997,7 +4002,11 @@ gtk_range_real_change_value (GtkRange      *range,
       priv->need_recalc = TRUE;
 
       gtk_widget_queue_draw (GTK_WIDGET (range));
-      gtk_adjustment_animate_to_value (priv->adjustment, value);
+
+      if (priv->in_drag)
+        gtk_adjustment_set_value (priv->adjustment, value);
+      else
+        gtk_adjustment_animate_to_value (priv->adjustment, value);
     }
 
   return FALSE;


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