diff options
author | Benjamin Otte <otte@redhat.com> | 2020-06-26 04:07:35 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2020-06-26 07:13:32 +0200 |
commit | dc1dbe6158945ac24b0fa076ead52db22b76dd54 (patch) | |
tree | f698f77db896e5ff58a013d1ca1ee3a728a2590e /gtk/gtklistbase.c | |
parent | 30488e60e292dfdb98fffc083083097ab793602e (diff) | |
download | gtk+-dc1dbe6158945ac24b0fa076ead52db22b76dd54.tar.gz |
listbase: Make rubberbanding a threshold drag
Diffstat (limited to 'gtk/gtklistbase.c')
-rw-r--r-- | gtk/gtklistbase.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/gtk/gtklistbase.c b/gtk/gtklistbase.c index edd68833df..5a1a38e40a 100644 --- a/gtk/gtklistbase.c +++ b/gtk/gtklistbase.c @@ -23,6 +23,7 @@ #include "gtkadjustment.h" #include "gtkbitset.h" +#include "gtkdragsource.h" #include "gtkdropcontrollermotion.h" #include "gtkgesturedrag.h" #include "gtkgizmoprivate.h" @@ -1697,22 +1698,24 @@ get_selection_modifiers (GtkGesture *gesture, } static void -gtk_list_base_drag_begin (GtkGestureDrag *gesture, - double start_x, - double start_y, - GtkListBase *self) -{ - gtk_list_base_start_rubberband (self, start_x, start_y); -} - -static void gtk_list_base_drag_update (GtkGestureDrag *gesture, double offset_x, double offset_y, GtkListBase *self) { + GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self); double start_x, start_y; + gtk_gesture_drag_get_start_point (gesture, &start_x, &start_y); + + if (!priv->rubberband) + { + if (!gtk_drag_check_threshold (GTK_WIDGET (self), 0, 0, offset_x, offset_y)) + return; + + gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED); + gtk_list_base_start_rubberband (self, start_x, start_y); + } gtk_list_base_update_rubberband (self, start_x + offset_x, start_y + offset_y); } @@ -1743,7 +1746,6 @@ gtk_list_base_set_enable_rubberband (GtkListBase *self, if (enable) { priv->drag_gesture = gtk_gesture_drag_new (); - g_signal_connect (priv->drag_gesture, "drag-begin", G_CALLBACK (gtk_list_base_drag_begin), self); g_signal_connect (priv->drag_gesture, "drag-update", G_CALLBACK (gtk_list_base_drag_update), self); g_signal_connect (priv->drag_gesture, "drag-end", G_CALLBACK (gtk_list_base_drag_end), self); gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (priv->drag_gesture)); |