diff --git a/gtk/gtkpixelcache.c b/gtk/gtkpixelcache.c index 2c0873e7a2..55d977e9d7 100644 --- a/gtk/gtkpixelcache.c +++ b/gtk/gtkpixelcache.c @@ -45,6 +45,9 @@ struct _GtkPixelCache { /* may be null if not dirty */ cairo_region_t *surface_dirty; + /* background tracking for rgb/rgba */ + GtkStyleContext *style_context; + guint timeout_tag; guint extra_width; @@ -88,6 +91,8 @@ _gtk_pixel_cache_free (GtkPixelCache *cache) if (cache->surface_dirty != NULL) cairo_region_destroy (cache->surface_dirty); + g_clear_object (&cache->style_context); + g_free (cache); } @@ -193,11 +198,8 @@ _gtk_pixel_cache_create_surface_if_needed (GtkPixelCache *cache, if (!content) { content = CAIRO_CONTENT_COLOR_ALPHA; - bg = gdk_window_get_background_pattern (window); - if (bg != NULL && - cairo_pattern_get_type (bg) == CAIRO_PATTERN_TYPE_SOLID && - cairo_pattern_get_rgba (bg, &red, &green, &blue, &alpha) == CAIRO_STATUS_SUCCESS && - alpha == 1.0) + if (cache->style_context && + _gtk_style_context_is_background_opaque (cache->style_context)) content = CAIRO_CONTENT_COLOR; } @@ -500,3 +502,11 @@ _gtk_pixel_cache_set_always_cache (GtkPixelCache *cache, { cache->always_cache = !!always_cache; } + +void +_gtk_pixel_cache_set_style_context (GtkPixelCache *cache, + GtkStyleContext *style_context) +{ + if (g_set_object (&cache->style_context, style_context)) + _gtk_pixel_cache_invalidate (cache, NULL); +} diff --git a/gtk/gtkpixelcacheprivate.h b/gtk/gtkpixelcacheprivate.h index 8e1122c36f..264717aab8 100644 --- a/gtk/gtkpixelcacheprivate.h +++ b/gtk/gtkpixelcacheprivate.h @@ -54,6 +54,8 @@ void _gtk_pixel_cache_set_content (GtkPixelCache *cache, gboolean _gtk_pixel_cache_get_always_cache (GtkPixelCache *cache); void _gtk_pixel_cache_set_always_cache (GtkPixelCache *cache, gboolean always_cache); +void _gtk_pixel_cache_set_style_context(GtkPixelCache *cache, + GtkStyleContext *style_context); G_END_DECLS