[gtk/wip/carlosg/for-master: 1/8] gtk/range: Move button release handling to GtkGestureDrag
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/carlosg/for-master: 1/8] gtk/range: Move button release handling to GtkGestureDrag
- Date: Sat, 12 Dec 2020 00:43:16 +0000 (UTC)
commit 7a4d15dc6799ba94388dfd598b5ad2401dfa90b7
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Dec 11 16:22:26 2020 +0100
gtk/range: Move button release handling to GtkGestureDrag
Tracking it through the GtkGestureClick becomes a bit cumbersome for
handling of simultaneously pressed buttons. We can track ::stopped,
but that also emits for a number of situations where we want drag to
continue.
However, the GtkGestureDrag is grouped with the click gesture, and
knows better when to finish the drag gesture (not just because of a
button release), so hook drag and zoom mode finalization there.
Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3426
gtk/gtkrange.c | 38 ++++++++++++++++++--------------------
1 file changed, 18 insertions(+), 20 deletions(-)
---
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index 650a9e292e..bf119199b0 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -168,11 +168,6 @@ static void gtk_range_click_gesture_pressed (GtkGestureClick *gesture,
double x,
double y,
GtkRange *range);
-static void gtk_range_click_gesture_released (GtkGestureClick *gesture,
- guint n_press,
- double x,
- double y,
- GtkRange *range);
static void gtk_range_drag_gesture_begin (GtkGestureDrag *gesture,
double offset_x,
double offset_y,
@@ -181,6 +176,10 @@ static void gtk_range_drag_gesture_update (GtkGestureDrag *gesture
double offset_x,
double offset_y,
GtkRange *range);
+static void gtk_range_drag_gesture_end (GtkGestureDrag *gesture,
+ double offset_x,
+ double offset_y,
+ GtkRange *range);
static void gtk_range_long_press_gesture_pressed (GtkGestureLongPress *gesture,
double x,
double y,
@@ -554,14 +553,14 @@ gtk_range_init (GtkRange *range)
G_CALLBACK (gtk_range_drag_gesture_begin), range);
g_signal_connect (priv->drag_gesture, "drag-update",
G_CALLBACK (gtk_range_drag_gesture_update), range);
+ g_signal_connect (priv->drag_gesture, "drag-end",
+ G_CALLBACK (gtk_range_drag_gesture_end), range);
gtk_widget_add_controller (GTK_WIDGET (range), GTK_EVENT_CONTROLLER (priv->drag_gesture));
gesture = gtk_gesture_click_new ();
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), 0);
g_signal_connect (gesture, "pressed",
G_CALLBACK (gtk_range_click_gesture_pressed), range);
- g_signal_connect (gesture, "released",
- G_CALLBACK (gtk_range_click_gesture_released), range);
gtk_widget_add_controller (GTK_WIDGET (range), GTK_EVENT_CONTROLLER (gesture));
gtk_gesture_group (gesture, priv->drag_gesture);
@@ -1976,19 +1975,6 @@ gtk_range_click_gesture_pressed (GtkGestureClick *gesture,
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
}
-static void
-gtk_range_click_gesture_released (GtkGestureClick *gesture,
- guint n_press,
- double x,
- double y,
- GtkRange *range)
-{
- GtkRangePrivate *priv = gtk_range_get_instance_private (range);
-
- priv->in_drag = FALSE;
- stop_scrolling (range);
-}
-
/* During a slide, move the slider as required given new mouse position */
static void
update_slider_position (GtkRange *range,
@@ -2301,6 +2287,18 @@ gtk_range_drag_gesture_begin (GtkGestureDrag *gesture,
gtk_gesture_set_state (priv->drag_gesture, GTK_EVENT_SEQUENCE_CLAIMED);
}
+static void
+gtk_range_drag_gesture_end (GtkGestureDrag *gesture,
+ double offset_x,
+ double offset_y,
+ GtkRange *range)
+{
+ GtkRangePrivate *priv = gtk_range_get_instance_private (range);
+
+ priv->in_drag = FALSE;
+ stop_scrolling (range);
+}
+
static void
gtk_range_adjustment_changed (GtkAdjustment *adjustment,
gpointer data)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]