summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-02-04 20:46:51 -0500
committerMatthias Clasen <mclasen@redhat.com>2021-02-04 20:47:19 -0500
commit15c36aaa1e0c287518c7cd7d6c83b8ef2ef805c0 (patch)
treee055dcf8464ace9ff4094492006c878668d5db4f
parent482b73c376118d353588a7164a5a5e027fcd0103 (diff)
downloadgtk+-15c36aaa1e0c287518c7cd7d6c83b8ef2ef805c0.tar.gz
iconbrowser: Make image dnd work again
We need to drag a texture, not a paintable. Fixes: #3648
-rw-r--r--demos/icon-browser/iconbrowserwin.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/demos/icon-browser/iconbrowserwin.c b/demos/icon-browser/iconbrowserwin.c
index 876c09a0d1..11c9c53234 100644
--- a/demos/icon-browser/iconbrowserwin.c
+++ b/demos/icon-browser/iconbrowserwin.c
@@ -279,11 +279,31 @@ drag_prepare_texture (GtkDragSource *source,
GtkWidget *widget)
{
GdkPaintable *paintable = get_image_paintable (GTK_IMAGE (widget));
+ GtkSnapshot *snapshot;
+ double width, height;
+ GskRenderNode *node;
+ GskRenderer *renderer;
+ GdkTexture *texture;
+ GdkContentProvider *ret;
if (!GDK_IS_PAINTABLE (paintable))
return NULL;
- return gdk_content_provider_new_typed (GDK_TYPE_PAINTABLE, paintable);
+ snapshot = gtk_snapshot_new ();
+ width = gdk_paintable_get_intrinsic_width (paintable);
+ height = gdk_paintable_get_intrinsic_height (paintable);
+ gdk_paintable_snapshot (paintable, snapshot, width, height);
+ node = gtk_snapshot_free_to_node (snapshot);
+
+ renderer = gtk_native_get_renderer (gtk_widget_get_native (widget));
+ texture = gsk_renderer_render_texture (renderer, node, &GRAPHENE_RECT_INIT (0, 0, width, height));
+
+ ret = gdk_content_provider_new_typed (GDK_TYPE_TEXTURE, texture);
+
+ g_object_unref (texture);
+ gsk_render_node_unref (node);
+
+ return ret;
}
static GdkContentProvider *