gtkwidget: read the draw border in place instead of copying it at every expose

This commit is contained in:
Daemonratte 2026-10-15 16:18:02 +02:00
commit fe26bf13ae
No known key found for this signature in database

View file

@ -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))