summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2022-05-05 17:16:40 -0400
committerMatthias Clasen <mclasen@redhat.com>2022-05-05 18:29:05 -0400
commite3abd7df5c9477c63576e33940f0f24449c0ff66 (patch)
treead4b3a223daac3fc98a4bbcd1d8c7b0e3558994d /tools
parenta0374334d4f210518438c9b6520ea4f6694ac9a1 (diff)
downloadgtk+-e3abd7df5c9477c63576e33940f0f24449c0ff66.tar.gz
builder-tool: Include shadows in screenshots
Remove the clipping to the widget area that GtkWidgetPaintable imposes, so we can see shadows and other out-of-bounds rendering. This is particularly useful for toplevel windows with client-side decorations.
Diffstat (limited to 'tools')
-rw-r--r--tools/gtk-builder-tool-screenshot.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/tools/gtk-builder-tool-screenshot.c b/tools/gtk-builder-tool-screenshot.c
index 17c3731d98..d53f5ac977 100644
--- a/tools/gtk-builder-tool-screenshot.c
+++ b/tools/gtk-builder-tool-screenshot.c
@@ -48,6 +48,7 @@ draw_paintable (GdkPaintable *paintable,
GskRenderNode *node;
GdkTexture *texture;
GskRenderer *renderer;
+ graphene_rect_t bounds;
snapshot = gtk_snapshot_new ();
gdk_paintable_snapshot (paintable,
@@ -62,16 +63,29 @@ draw_paintable (GdkPaintable *paintable,
if (node == NULL)
return;
+ if (gsk_render_node_get_node_type (node) == GSK_CLIP_NODE)
+ {
+ GskRenderNode *child;
+
+ child = gsk_render_node_ref (gsk_clip_node_get_child (node));
+ gsk_render_node_unref (node);
+ node = child;
+ }
+
renderer = gtk_native_get_renderer (
gtk_widget_get_native (
gtk_widget_paintable_get_widget (GTK_WIDGET_PAINTABLE (paintable))));
- texture = gsk_renderer_render_texture (renderer,
- node,
- &GRAPHENE_RECT_INIT (
- 0, 0,
- gdk_paintable_get_intrinsic_width (paintable),
- gdk_paintable_get_intrinsic_height (paintable)
- ));
+
+ gsk_render_node_get_bounds (node, &bounds);
+ graphene_rect_union (&bounds,
+ &GRAPHENE_RECT_INIT (
+ 0, 0,
+ gdk_paintable_get_intrinsic_width (paintable),
+ gdk_paintable_get_intrinsic_height (paintable)
+ ),
+ &bounds);
+
+ texture = gsk_renderer_render_texture (renderer, node, &bounds);
g_object_set_data_full (G_OBJECT (texture),
"source-render-node",
node,