summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2023-04-09 13:02:55 +0000
committerMatthias Clasen <mclasen@redhat.com>2023-04-09 13:02:55 +0000
commitcefd7207895f558cfa544d1bb1188b95a12a7026 (patch)
treec772f2839a3d459966ec32f6257d35ce1d3564c5
parent61a0d063108f160d966d65e3a031e921906d57a2 (diff)
parentd4a34b1a0b98c961baf269a48adfebc4154b5f48 (diff)
downloadgtk+-cefd7207895f558cfa544d1bb1188b95a12a7026.tar.gz
Merge branch 'matthiasc/for-main' into 'main'
gtk-demo: Add a keyword See merge request GNOME/gtk!5805
-rw-r--r--demos/gtk-demo/bluroverlay.c23
-rw-r--r--demos/gtk-demo/paint.c6
-rw-r--r--demos/gtk-demo/transparent.c2
3 files changed, 17 insertions, 14 deletions
diff --git a/demos/gtk-demo/bluroverlay.c b/demos/gtk-demo/bluroverlay.c
index 3a7585ff09..a4f1d450fd 100644
--- a/demos/gtk-demo/bluroverlay.c
+++ b/demos/gtk-demo/bluroverlay.c
@@ -297,12 +297,13 @@ blur_overlay_snapshot (GtkWidget *widget,
GtkWidget *main_widget;
GskRenderNode *main_widget_node = NULL;
GtkWidget *child;
- GtkAllocation main_alloc;
+ int width, height;
cairo_region_t *clip = NULL;
int i;
main_widget = BLUR_OVERLAY (widget)->main_widget;
- gtk_widget_get_allocation (widget, &main_alloc);
+ width = gtk_widget_get_width (widget);
+ height = gtk_widget_get_height (widget);
for (child = gtk_widget_get_first_child (widget);
child != NULL;
@@ -315,7 +316,7 @@ blur_overlay_snapshot (GtkWidget *widget,
if (blur > 0)
{
- GtkAllocation alloc;
+ cairo_rectangle_int_t rect;
graphene_rect_t bounds;
if (main_widget_node == NULL)
@@ -327,8 +328,8 @@ blur_overlay_snapshot (GtkWidget *widget,
main_widget_node = gtk_snapshot_free_to_node (child_snapshot);
}
- gtk_widget_get_allocation (child, &alloc);
- graphene_rect_init (&bounds, alloc.x, alloc.y, alloc.width, alloc.height);
+ if (!gtk_widget_compute_bounds (child, gtk_widget_get_parent (child), &bounds))
+ graphene_rect_init (&bounds, 0, 0, 0, 0);
gtk_snapshot_push_blur (snapshot, blur);
gtk_snapshot_push_clip (snapshot, &bounds);
gtk_snapshot_append_node (snapshot, main_widget_node);
@@ -337,13 +338,17 @@ blur_overlay_snapshot (GtkWidget *widget,
if (clip == NULL)
{
- cairo_rectangle_int_t rect;
rect.x = rect.y = 0;
- rect.width = main_alloc.width;
- rect.height = main_alloc.height;
+ rect.width = width;
+ rect.height = height;
clip = cairo_region_create_rectangle (&rect);
}
- cairo_region_subtract_rectangle (clip, (cairo_rectangle_int_t *)&alloc);
+
+ rect.x = floor (bounds.origin.x);
+ rect.y = floor (bounds.origin.y);
+ rect.width = ceil (bounds.origin.x + bounds.size.width - rect.x);
+ rect.height = ceil (bounds.origin.y + bounds.size.height - rect.y);
+ cairo_region_subtract_rectangle (clip, &rect);
}
}
diff --git a/demos/gtk-demo/paint.c b/demos/gtk-demo/paint.c
index 1696ca8e99..34830284b9 100644
--- a/demos/gtk-demo/paint.c
+++ b/demos/gtk-demo/paint.c
@@ -103,13 +103,11 @@ drawing_area_size_allocate (GtkWidget *widget,
static void
drawing_area_map (GtkWidget *widget)
{
- GtkAllocation allocation;
-
GTK_WIDGET_CLASS (drawing_area_parent_class)->map (widget);
- gtk_widget_get_allocation (widget, &allocation);
drawing_area_ensure_surface ((DrawingArea *) widget,
- allocation.width, allocation.height);
+ gtk_widget_get_width (widget),
+ gtk_widget_get_height (widget));
}
static void
diff --git a/demos/gtk-demo/transparent.c b/demos/gtk-demo/transparent.c
index 10d9e81da0..626ef2c43d 100644
--- a/demos/gtk-demo/transparent.c
+++ b/demos/gtk-demo/transparent.c
@@ -1,5 +1,5 @@
/* Overlay/Transparency
- * #Keywords: GtkOverlay, GtkSnapshot
+ * #Keywords: GtkOverlay, GtkSnapshot, blur
*
* Blur the background behind an overlay.
*/