From fe26bf13aeab44ff5cf8ef92db4669699cb5901b Mon Sep 17 00:00:00 2001 From: Daemonratte Date: Thu, 15 Oct 2026 16:18:02 +0200 Subject: [PATCH] gtkwidget: read the draw border in place instead of copying it at every expose --- gtk/gtkwidget.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 2cdca0971..53196014a 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -393,6 +393,9 @@ typedef struct GtkRcPropertyParser parser; } StylePropertyCacheEntry; static StylePropertyCacheEntry style_property_cache[STYLE_PROPERTY_CACHE_SIZE]; +static GParamSpec *style_property_lookup (GType type, + const gchar *name, + GtkRcPropertyParser *parser); static GQuark quark_property_parser = 0; static GQuark quark_aux_info = 0; @@ -3760,21 +3763,24 @@ gtk_widget_get_draw_rectangle (GtkWidget *widget, { if (!gtk_widget_get_has_window (widget)) { - GtkBorder *draw_border = NULL; + const GtkBorder *draw_border; + GtkRcPropertyParser parser; + GParamSpec *pspec; *rect = widget->allocation; - gtk_widget_style_get (widget, - "draw-border", &draw_border, - NULL); + /* this runs for every child at every expose: look at the + * value instead of asking for a copy of it */ + pspec = style_property_lookup (G_OBJECT_TYPE (widget), "draw-border", &parser); + draw_border = g_value_get_boxed (_gtk_style_peek_property_value (widget->style, + G_OBJECT_TYPE (widget), + pspec, parser)); if (draw_border) { rect->x -= draw_border->left; rect->y -= draw_border->top; rect->width += draw_border->left + draw_border->right; rect->height += draw_border->top + draw_border->bottom; - - gtk_border_free (draw_border); } if (GTK_IS_CONTAINER (widget))