From: Matthias Clasen Date: Sat, 20 Jun 2015 22:37:15 +0000 (-0400) Subject: GtkRange: Make drag gesture less agressive X-Git-Tag: archive/raspbian/4.4.1+ds1-2+rpi1^2~18^2~24^2~9316 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=27dabaefa6f6edee78e05e6a76fccf20be2c7679;p=gtk4.git 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 --- diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c index 3ed84343c0..2f7cae5af6 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