pixelcache: Don't have a style context argument
That would imply the pixelcache monitors the style context for changes and it doesn't do that. Its only use case was opacity checks, so add gtk_pixel_cache_se_is_opaque() instead.
This commit is contained in:
parent
71a9fd9d83
commit
4e8fb33f56
@ -47,15 +47,13 @@ struct _GtkPixelCache {
|
|||||||
/* may be null if not dirty */
|
/* may be null if not dirty */
|
||||||
cairo_region_t *surface_dirty;
|
cairo_region_t *surface_dirty;
|
||||||
|
|
||||||
/* background tracking for rgb/rgba */
|
|
||||||
GtkStyleContext *style_context;
|
|
||||||
|
|
||||||
guint timeout_tag;
|
guint timeout_tag;
|
||||||
|
|
||||||
guint extra_width;
|
guint extra_width;
|
||||||
guint extra_height;
|
guint extra_height;
|
||||||
|
|
||||||
guint always_cache : 1;
|
guint always_cache : 1;
|
||||||
|
guint is_opaque : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
GtkPixelCache *
|
GtkPixelCache *
|
||||||
@ -93,8 +91,6 @@ _gtk_pixel_cache_free (GtkPixelCache *cache)
|
|||||||
if (cache->surface_dirty != NULL)
|
if (cache->surface_dirty != NULL)
|
||||||
cairo_region_destroy (cache->surface_dirty);
|
cairo_region_destroy (cache->surface_dirty);
|
||||||
|
|
||||||
g_clear_object (&cache->style_context);
|
|
||||||
|
|
||||||
g_free (cache);
|
g_free (cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,10 +193,10 @@ _gtk_pixel_cache_create_surface_if_needed (GtkPixelCache *cache,
|
|||||||
content = cache->content;
|
content = cache->content;
|
||||||
if (!content)
|
if (!content)
|
||||||
{
|
{
|
||||||
content = CAIRO_CONTENT_COLOR_ALPHA;
|
if (cache->is_opaque)
|
||||||
if (cache->style_context &&
|
|
||||||
gtk_css_style_render_background_is_opaque (gtk_style_context_lookup_style (cache->style_context)))
|
|
||||||
content = CAIRO_CONTENT_COLOR;
|
content = CAIRO_CONTENT_COLOR;
|
||||||
|
else
|
||||||
|
content = CAIRO_CONTENT_COLOR_ALPHA;
|
||||||
}
|
}
|
||||||
|
|
||||||
surface_w = view_rect->width;
|
surface_w = view_rect->width;
|
||||||
@ -504,9 +500,12 @@ _gtk_pixel_cache_set_always_cache (GtkPixelCache *cache,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_gtk_pixel_cache_set_style_context (GtkPixelCache *cache,
|
gtk_pixel_cache_set_is_opaque (GtkPixelCache *cache,
|
||||||
GtkStyleContext *style_context)
|
gboolean is_opaque)
|
||||||
{
|
{
|
||||||
if (g_set_object (&cache->style_context, style_context))
|
if (cache->is_opaque == is_opaque)
|
||||||
|
return;
|
||||||
|
|
||||||
|
cache->is_opaque = is_opaque;
|
||||||
_gtk_pixel_cache_invalidate (cache, NULL);
|
_gtk_pixel_cache_invalidate (cache, NULL);
|
||||||
}
|
}
|
||||||
|
@ -54,8 +54,8 @@ void _gtk_pixel_cache_set_content (GtkPixelCache *cache,
|
|||||||
gboolean _gtk_pixel_cache_get_always_cache (GtkPixelCache *cache);
|
gboolean _gtk_pixel_cache_get_always_cache (GtkPixelCache *cache);
|
||||||
void _gtk_pixel_cache_set_always_cache (GtkPixelCache *cache,
|
void _gtk_pixel_cache_set_always_cache (GtkPixelCache *cache,
|
||||||
gboolean always_cache);
|
gboolean always_cache);
|
||||||
void _gtk_pixel_cache_set_style_context(GtkPixelCache *cache,
|
void gtk_pixel_cache_set_is_opaque (GtkPixelCache *cache,
|
||||||
GtkStyleContext *style_context);
|
gboolean is_opaque);
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#include "gtkmarshalers.h"
|
#include "gtkmarshalers.h"
|
||||||
#include "gtkmenu.h"
|
#include "gtkmenu.h"
|
||||||
#include "gtkmenuitem.h"
|
#include "gtkmenuitem.h"
|
||||||
|
#include "gtkrenderbackgroundprivate.h"
|
||||||
#include "gtkseparatormenuitem.h"
|
#include "gtkseparatormenuitem.h"
|
||||||
#include "gtksettings.h"
|
#include "gtksettings.h"
|
||||||
#include "gtkselectionprivate.h"
|
#include "gtkselectionprivate.h"
|
||||||
@ -51,7 +52,6 @@
|
|||||||
#include "gtkscrollable.h"
|
#include "gtkscrollable.h"
|
||||||
#include "gtktypebuiltins.h"
|
#include "gtktypebuiltins.h"
|
||||||
#include "gtktexthandleprivate.h"
|
#include "gtktexthandleprivate.h"
|
||||||
#include "gtkstylecontextprivate.h"
|
|
||||||
#include "gtkcssstylepropertyprivate.h"
|
#include "gtkcssstylepropertyprivate.h"
|
||||||
#include "gtkpopover.h"
|
#include "gtkpopover.h"
|
||||||
#include "gtktoolbar.h"
|
#include "gtktoolbar.h"
|
||||||
@ -1685,7 +1685,6 @@ gtk_text_view_init (GtkTextView *text_view)
|
|||||||
|
|
||||||
context = gtk_widget_get_style_context (GTK_WIDGET (text_view));
|
context = gtk_widget_get_style_context (GTK_WIDGET (text_view));
|
||||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_VIEW);
|
gtk_style_context_add_class (context, GTK_STYLE_CLASS_VIEW);
|
||||||
_gtk_pixel_cache_set_style_context (priv->pixel_cache, context);
|
|
||||||
|
|
||||||
/* Set up default style */
|
/* Set up default style */
|
||||||
priv->wrap_mode = GTK_WRAP_NONE;
|
priv->wrap_mode = GTK_WRAP_NONE;
|
||||||
@ -9775,10 +9774,18 @@ node_style_changed_cb (GtkCssNode *node,
|
|||||||
GtkCssStyleChange *change,
|
GtkCssStyleChange *change,
|
||||||
GtkWidget *widget)
|
GtkWidget *widget)
|
||||||
{
|
{
|
||||||
|
GtkTextViewPrivate *priv = GTK_TEXT_VIEW (widget)->priv;
|
||||||
|
|
||||||
if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP))
|
if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP))
|
||||||
gtk_widget_queue_resize (widget);
|
gtk_widget_queue_resize (widget);
|
||||||
else
|
else
|
||||||
gtk_widget_queue_draw (widget);
|
gtk_widget_queue_draw (widget);
|
||||||
|
|
||||||
|
if (node == priv->text_window->css_node)
|
||||||
|
{
|
||||||
|
GtkCssStyle *style = gtk_css_style_change_get_new_style (change);
|
||||||
|
gtk_pixel_cache_set_is_opaque (priv->pixel_cache, gtk_css_style_render_background_is_opaque (style));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -33,7 +33,8 @@
|
|||||||
#include "gtkpixelcacheprivate.h"
|
#include "gtkpixelcacheprivate.h"
|
||||||
#include "gtkprivate.h"
|
#include "gtkprivate.h"
|
||||||
#include "gtkscrollable.h"
|
#include "gtkscrollable.h"
|
||||||
#include "gtkrender.h"
|
#include "gtkrenderbackgroundprivate.h"
|
||||||
|
#include "gtkstylecontextprivate.h"
|
||||||
#include "gtktypebuiltins.h"
|
#include "gtktypebuiltins.h"
|
||||||
#include "gtkwidgetprivate.h"
|
#include "gtkwidgetprivate.h"
|
||||||
|
|
||||||
@ -937,6 +938,18 @@ gtk_viewport_draw (GtkWidget *widget,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_viewport_update_pixelcache_opacity (GtkWidget *child,
|
||||||
|
GtkViewport *viewport)
|
||||||
|
{
|
||||||
|
GtkViewportPrivate *priv = viewport->priv;
|
||||||
|
|
||||||
|
gtk_pixel_cache_set_is_opaque (priv->pixel_cache,
|
||||||
|
gtk_css_style_render_background_is_opaque (
|
||||||
|
gtk_style_context_lookup_style (
|
||||||
|
gtk_widget_get_style_context (child))));
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_viewport_remove (GtkContainer *container,
|
gtk_viewport_remove (GtkContainer *container,
|
||||||
GtkWidget *child)
|
GtkWidget *child)
|
||||||
@ -944,10 +957,14 @@ gtk_viewport_remove (GtkContainer *container,
|
|||||||
GtkViewport *viewport = GTK_VIEWPORT (container);
|
GtkViewport *viewport = GTK_VIEWPORT (container);
|
||||||
GtkViewportPrivate *priv = viewport->priv;
|
GtkViewportPrivate *priv = viewport->priv;
|
||||||
|
|
||||||
|
if (g_signal_handlers_disconnect_by_func (child, gtk_viewport_update_pixelcache_opacity, viewport) != 1)
|
||||||
|
{
|
||||||
|
g_assert_not_reached ();
|
||||||
|
}
|
||||||
|
|
||||||
GTK_CONTAINER_CLASS (gtk_viewport_parent_class)->remove (container, child);
|
GTK_CONTAINER_CLASS (gtk_viewport_parent_class)->remove (container, child);
|
||||||
|
|
||||||
_gtk_pixel_cache_set_style_context (priv->pixel_cache, NULL);
|
gtk_pixel_cache_set_is_opaque (priv->pixel_cache, FALSE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -962,10 +979,10 @@ gtk_viewport_add (GtkContainer *container,
|
|||||||
|
|
||||||
gtk_widget_set_parent_window (child, priv->bin_window);
|
gtk_widget_set_parent_window (child, priv->bin_window);
|
||||||
|
|
||||||
_gtk_pixel_cache_set_style_context (priv->pixel_cache,
|
|
||||||
gtk_widget_get_style_context (child));
|
|
||||||
|
|
||||||
GTK_CONTAINER_CLASS (gtk_viewport_parent_class)->add (container, child);
|
GTK_CONTAINER_CLASS (gtk_viewport_parent_class)->add (container, child);
|
||||||
|
|
||||||
|
g_signal_connect (child, "style-updated", G_CALLBACK (gtk_viewport_update_pixelcache_opacity), viewport);
|
||||||
|
gtk_viewport_update_pixelcache_opacity (child, viewport);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user