[gtk+/gtk-3-16] GtkRange: Make drag gesture less agressive



commit 8d3fb714f0842dd05f5d34a9ebea6cc6858ccf0f
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jun 20 18:37:15 2015 -0400

    GtkRange: Make drag gesture less agressive
    
    Moving the mouse while pressing one of the steppers was making
    the slider jump to the end, unexpectedly. This was caused by the
    drag gesture kicking in when it shouldn't. Fix this by making
    all drag gesture signal handlers only do something if we are in
    a drag thats started on the slider.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=751050

 gtk/gtkrange.c |   27 ++++++++++++++++-----------
 1 files changed, 16 insertions(+), 11 deletions(-)
---
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index 3ed8434..2f7cae5 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -2286,7 +2286,7 @@ range_grab_remove (GtkRange *range)
 }
 
 static GtkScrollType
-range_get_scroll_for_grab (GtkRange      *range)
+range_get_scroll_for_grab (GtkRange *range)
 {
   GtkRangePrivate *priv = range->priv;
   guint grab_button;
@@ -2397,7 +2397,6 @@ coord_to_value (GtkRange *range,
   value = gtk_adjustment_get_lower (priv->adjustment) + frac * (gtk_adjustment_get_upper (priv->adjustment) -
                                             gtk_adjustment_get_lower (priv->adjustment) -
                                             gtk_adjustment_get_page_size (priv->adjustment));
-
   return value;
 }
 
@@ -2925,15 +2924,18 @@ gtk_range_drag_gesture_update (GtkGestureDrag *gesture,
   GtkRangePrivate *priv = range->priv;
   gdouble start_x, start_y;
 
-  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;
+  if (range->priv->grab_location == MOUSE_SLIDER)
+    {
+      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);
+      update_autoscroll_mode (range);
 
-  if (priv->autoscroll_mode == GTK_SCROLL_NONE)
-    update_slider_position (range, priv->mouse_x, priv->mouse_y);
+      if (priv->autoscroll_mode == GTK_SCROLL_NONE)
+        update_slider_position (range, priv->mouse_x, priv->mouse_y);
+    }
 }
 
 static void
@@ -2952,8 +2954,11 @@ gtk_range_drag_gesture_end (GtkGestureDrag       *gesture,
                             gdouble               offset_y,
                             GtkRange             *range)
 {
-  range->priv->in_drag = FALSE;
-  stop_scrolling (range);
+  if (range->priv->grab_location == MOUSE_SLIDER)
+    {
+      range->priv->in_drag = FALSE;
+      stop_scrolling (range);
+    }
 }
 
 static gboolean


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