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



commit ced54098af802a2862357147033a80b76ed87717
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 d3e5a5d..b73e8e4 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -2300,7 +2300,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;
@@ -2411,7 +2411,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;
 }
 
@@ -2922,15 +2921,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
@@ -2949,8 +2951,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]