[gtk/matthiasc/for-master: 2/2] text: Stop drag updates when a dnd starts
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master: 2/2] text: Stop drag updates when a dnd starts
- Date: Sun, 6 Sep 2020 16:20:52 +0000 (UTC)
commit adc9d91e0e4493d7cc955ff5c8a2b79e3e831007
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Sep 6 12:19:44 2020 -0400
text: Stop drag updates when a dnd starts
This prevents the selection from changing underneath
us, messing up move dnd operations.
gtk/gtktext.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
---
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index 6af06f39fe..7e2f2308eb 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -2910,6 +2910,16 @@ dnd_finished_cb (GdkDrag *drag,
priv->drag = NULL;
}
+static void
+dnd_cancel_cb (GdkDrag *drag,
+ GdkDragCancelReason reason,
+ GtkText *self)
+{
+ GtkTextPrivate *priv = gtk_text_get_instance_private (self);
+
+ priv->drag = NULL;
+}
+
static void
gtk_text_drag_gesture_update (GtkGestureDrag *gesture,
double offset_x,
@@ -2973,6 +2983,7 @@ gtk_text_drag_gesture_update (GtkGestureDrag *gesture,
g_object_unref (content);
g_signal_connect (drag, "dnd-finished", G_CALLBACK (dnd_finished_cb), self);
+ g_signal_connect (drag, "cancel", G_CALLBACK (dnd_cancel_cb), self);
paintable = gtk_text_util_create_drag_icon (widget, text, -1);
gtk_drag_icon_set_from_paintable (drag, paintable, ranges[0], 0);
@@ -2986,6 +2997,9 @@ gtk_text_drag_gesture_update (GtkGestureDrag *gesture,
g_free (text);
priv->in_drag = FALSE;
+
+ /* Deny the gesture so we don't get further updates */
+ gtk_gesture_set_state (priv->drag_gesture, GTK_EVENT_SEQUENCE_DENIED);
}
}
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]