text: Stop drag updates when a dnd starts

This prevents the selection from changing underneath
us, messing up move dnd operations.
This commit is contained in:
Matthias Clasen 2020-09-06 12:19:44 -04:00
parent 9b8c175f23
commit adc9d91e0e

View File

@ -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