From 40e7638a4b12ef3c68e87d20963e40fccaedfe14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 11 May 2017 06:35:09 +0200 Subject: [PATCH] st-icon: Add resource-scale support This commit adds support for scaling the StIcon resource (the icon texture) according to the resource scale. https://bugzilla.gnome.org/show_bug.cgi?id=765011 --- src/st/st-icon.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/st/st-icon.c b/src/st/st-icon.c index 9242d6b4e..04d2d1d3c 100644 --- a/src/st/st-icon.c +++ b/src/st/st-icon.c @@ -210,6 +210,12 @@ st_icon_style_changed (StWidget *widget) st_icon_update (self); } +static void +st_icon_resource_scale_changed (StWidget *widget) +{ + st_icon_update (ST_ICON (widget)); +} + static void st_icon_class_init (StIconClass *klass) { @@ -226,6 +232,7 @@ st_icon_class_init (StIconClass *klass) actor_class->paint = st_icon_paint; widget_class->style_changed = st_icon_style_changed; + widget_class->resource_scale_changed = st_icon_resource_scale_changed; pspec = g_param_spec_object ("gicon", "GIcon", @@ -344,6 +351,8 @@ st_icon_finish_update (StIcon *icon) g_signal_connect_object (priv->icon_texture, "notify::content", G_CALLBACK (on_content_changed), icon, 0); } + + clutter_actor_queue_relayout (CLUTTER_ACTOR (icon)); } static void @@ -366,9 +375,10 @@ st_icon_update (StIcon *icon) StIconPrivate *priv = icon->priv; StThemeNode *theme_node; StTextureCache *cache; - gint scale; + gint paint_scale; ClutterActor *stage; StThemeContext *context; + float resource_scale; if (priv->pending_texture) { @@ -378,13 +388,16 @@ st_icon_update (StIcon *icon) priv->opacity_handler_id = 0; } + if (!st_widget_get_resource_scale (ST_WIDGET (icon), &resource_scale)) + return; + theme_node = st_widget_peek_theme_node (ST_WIDGET (icon)); if (theme_node == NULL) return; stage = clutter_actor_get_stage (CLUTTER_ACTOR (icon)); context = st_theme_context_get_for_stage (CLUTTER_STAGE (stage)); - g_object_get (context, "scale-factor", &scale, NULL); + g_object_get (context, "scale-factor", &paint_scale, NULL); cache = st_texture_cache_get_default (); @@ -393,16 +406,16 @@ st_icon_update (StIcon *icon) theme_node, priv->gicon, priv->icon_size, - scale, - 1); + paint_scale, + resource_scale); if (priv->pending_texture == NULL && priv->fallback_gicon != NULL) priv->pending_texture = st_texture_cache_load_gicon (cache, theme_node, priv->fallback_gicon, priv->icon_size, - scale, - 1); + paint_scale, + resource_scale); if (priv->pending_texture) {