From: Matthias Clasen Date: Tue, 7 Jan 2020 05:26:30 +0000 (-0500) Subject: text: Fix dragging of text across focus changes X-Git-Tag: archive/raspbian/4.4.1+ds1-2+rpi1^2~18^2~20^2~354^2~52 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=a04d3149108bd1054a9fc10a111ca9f1c779aead;p=gtk4.git 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. --- diff --git a/gtk/gtktext.c b/gtk/gtktext.c index 1304a29f9c..9d2c690d76 100644 --- a/gtk/gtktext.c +++ b/gtk/gtktext.c @@ -2845,6 +2845,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); @@ -2854,12 +2856,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);