[gtk/dnd-gestures-2: 135/150] text: Fix dragging of text across focus changes
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/dnd-gestures-2: 135/150] text: Fix dragging of text across focus changes
- Date: Tue, 7 Jan 2020 07:03:16 +0000 (UTC)
commit a7d7d06d233c0ea60e757fa4ba4ab1b35c5e1568
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Jan 7 00:26:30 2020 -0500
text: Fix dragging of text across focus changes
When dragging selected text from an entry over a stackswitcher
to show a different page, the focus changes, causing the selection
to be lost; we should not lose the dragged content in this case.
gtk/gtktext.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index ec9c119718..1d89f7ef65 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -2843,6 +2843,8 @@ gtk_text_drag_gesture_update (GtkGestureDrag *gesture,
GdkDragAction actions;
GdkDrag *drag;
GdkPaintable *paintable;
+ GdkContentProvider *content;
+ GValue value = G_VALUE_INIT;
text = _gtk_text_get_selected_text (self);
gtk_text_get_pixel_ranges (self, &ranges, &n_ranges);
@@ -2852,12 +2854,18 @@ gtk_text_drag_gesture_update (GtkGestureDrag *gesture,
else
actions = GDK_ACTION_COPY;
+ g_value_init (&value, G_TYPE_STRING);
+ g_value_set_string (&value, text);
+ content = gdk_content_provider_new_for_value (&value);
+ g_value_unset (&value);
+
drag = gdk_drag_begin (gdk_event_get_surface ((GdkEvent*) event),
gdk_event_get_device ((GdkEvent*) event),
- priv->selection_content,
+ content,
actions,
priv->drag_start_x,
priv->drag_start_y);
+ g_object_unref (content);
g_signal_connect (drag, "dnd-finished", G_CALLBACK (dnd_finished_cb), self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]