Compare commits

...

4 Commits

Author SHA1 Message Date
Georges Basile Stavracas Neto
966d4b164c st/theme-context: Invalidate texture cache when scaling changes 2020-04-03 19:01:08 -03:00
Georges Basile Stavracas Neto
a3cf41734a appDisplay: Set the folder icon geometry through CSS
The CSS engine is scale-aware, whereas simply setting the
width and height properties directly isn't.

Use CSS to set the folder icon.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1176
2020-04-03 18:20:57 -03:00
Georges Basile Stavracas Neto
76811b4ebc st/theme-node: Use the node's scale factor
Each node stores the scale factor in place when it was created.
Creating nodes with the same style, but with different scale
factors, yields different nodes.

Use the node's scale factor instead of retrieving the context's
one.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1176
2020-04-03 18:20:57 -03:00
Georges Basile Stavracas Neto
2721c306af st/theme-node: Consider scale factor when comparing
The CSS engine of St is scale-aware, which means every length
and size it produces is multiplied by the current scale factor.

However, the individual nodes aren't aware of the scale factor
when they compare to each other.

Store and compare the scale factors in the nodes themselves.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/1635

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1176
2020-04-03 18:20:57 -03:00
6 changed files with 35 additions and 13 deletions

View File

@ -1376,12 +1376,12 @@ class FolderView extends BaseAppView {
});
layout.hookup_style(icon);
let subSize = Math.floor(FOLDER_SUBICON_FRACTION * size);
let scale = St.ThemeContext.get_for_stage(global.stage).scale_factor;
let numItems = this._orderedItems.length;
let rtl = icon.get_text_direction() == Clutter.TextDirection.RTL;
for (let i = 0; i < 4; i++) {
let bin = new St.Bin({ width: subSize * scale, height: subSize * scale });
const style = 'width: %dpx; height: %dpx;'.format(subSize, subSize);
let bin = new St.Bin({ style });
if (i < numItems)
bin.child = this._orderedItems[i].app.create_icon_texture(subSize);
layout.attach(bin, rtl ? (i + 1) % 2 : i % 2, Math.floor(i / 2), 1, 1);

View File

@ -1619,3 +1619,18 @@ st_texture_cache_rescan_icon_theme (StTextureCache *cache)
return gtk_icon_theme_rescan_if_needed (priv->icon_theme);
}
/**
* st_texture_cache_invalidate:
* @cache: a #StTextureCache
*
* Invalidates the texture cache, and evicts all icons.
*/
void
st_texture_cache_invalidate (StTextureCache *cache)
{
g_return_if_fail (ST_IS_TEXTURE_CACHE (cache));
st_texture_cache_evict_icons (cache);
}

View File

@ -115,4 +115,6 @@ CoglTexture * st_texture_cache_load (StTextureCache *cache,
gboolean st_texture_cache_rescan_icon_theme (StTextureCache *cache);
void st_texture_cache_invalidate (StTextureCache *cache);
#endif /* __ST_TEXTURE_CACHE_H__ */

View File

@ -176,7 +176,11 @@ st_theme_context_set_property (GObject *object,
int scale_factor = g_value_get_int (value);
if (scale_factor != context->scale_factor)
{
StTextureCache *cache = st_texture_cache_get_default ();
context->scale_factor = scale_factor;
st_texture_cache_invalidate (cache);
st_theme_context_changed (context);
}

View File

@ -117,6 +117,8 @@ struct _StThemeNode {
CoglPipeline *color_pipeline;
StThemeNodePaintState cached_state;
int scale_factor;
};
void _st_theme_node_ensure_background (StThemeNode *node);

View File

@ -219,6 +219,8 @@ st_theme_node_new (StThemeContext *context,
if (theme == NULL && parent_node != NULL)
theme = parent_node->theme;
g_object_get (context, "scale-factor", &node->scale_factor, NULL);
g_set_object (&node->theme, theme);
node->element_type = element_type;
node->element_id = g_strdup (element_id);
@ -345,6 +347,7 @@ st_theme_node_equal (StThemeNode *node_a, StThemeNode *node_b)
node_a->context != node_b->context ||
node_a->theme != node_b->theme ||
node_a->element_type != node_b->element_type ||
node_a->scale_factor != node_b->scale_factor ||
g_strcmp0 (node_a->element_id, node_b->element_id) ||
g_strcmp0 (node_a->inline_style, node_b->inline_style))
return FALSE;
@ -396,6 +399,7 @@ st_theme_node_hash (StThemeNode *node)
hash = hash * 33 + GPOINTER_TO_UINT (node->context);
hash = hash * 33 + GPOINTER_TO_UINT (node->theme);
hash = hash * 33 + ((guint) node->element_type);
hash = hash * 33 + ((guint) node->scale_factor);
if (node->element_id != NULL)
hash = hash * 33 + g_str_hash (node->element_id);
@ -975,9 +979,7 @@ get_length_from_term (StThemeNode *node,
} type = ABSOLUTE;
double multiplier = 1.0;
int scale_factor;
g_object_get (node->context, "scale-factor", &scale_factor, NULL);
if (term->type != TERM_NUMBER)
{
@ -992,7 +994,7 @@ get_length_from_term (StThemeNode *node,
{
case NUM_LENGTH_PX:
type = ABSOLUTE;
multiplier = 1 * scale_factor;
multiplier = 1 * node->scale_factor;
break;
case NUM_LENGTH_PT:
type = POINTS;
@ -1123,14 +1125,10 @@ get_length_from_term_int (StThemeNode *node,
{
double value;
GetFromTermResult result;
int scale_factor;
result = get_length_from_term (node, term, use_parent_font, &value);
if (result == VALUE_FOUND)
{
g_object_get (node->context, "scale-factor", &scale_factor, NULL);
*length = (int) ((value / scale_factor) + 0.5) * scale_factor;
}
*length = (int) ((value / node->scale_factor) + 0.5) * node->scale_factor;
return result;
}
@ -3012,7 +3010,6 @@ StBorderImage *
st_theme_node_get_border_image (StThemeNode *node)
{
int i;
int scale_factor;
if (node->border_image_computed)
return node->border_image;
@ -3021,7 +3018,6 @@ st_theme_node_get_border_image (StThemeNode *node)
node->border_image_computed = TRUE;
ensure_properties (node);
g_object_get (node->context, "scale-factor", &scale_factor, NULL);
for (i = node->n_properties - 1; i >= 0; i--)
{
@ -3126,7 +3122,7 @@ st_theme_node_get_border_image (StThemeNode *node)
node->border_image = st_border_image_new (file,
border_top, border_right, border_bottom, border_left,
scale_factor);
node->scale_factor);
g_object_unref (file);
@ -3967,6 +3963,9 @@ st_theme_node_geometry_equal (StThemeNode *node,
g_return_val_if_fail (ST_IS_THEME_NODE (other), FALSE);
if (node->scale_factor != other->scale_factor)
return FALSE;
_st_theme_node_ensure_geometry (node);
_st_theme_node_ensure_geometry (other);