st/texture-cache: Ensure icons keep their aspect ratio when scaled down

Window preview icons can get scaled down if the window they belong to is
very small and/or there are a lot of open windows. When scaled down this
way the icons would get scaled without keeping the aspect ratio. Fix
this by using a content gravity that keeps the aspect ratio.

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

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1751>
This commit is contained in:
Sebastian Keller 2021-03-10 17:27:42 +01:00 committed by Marge Bot
parent 07f2d32087
commit 5062c4c9c2

View File

@ -983,6 +983,7 @@ st_texture_cache_load_gicon (StTextureCache *cache,
if (ST_IS_IMAGE_CONTENT (icon))
{
return g_object_new (CLUTTER_TYPE_ACTOR,
"content-gravity", CLUTTER_CONTENT_GRAVITY_RESIZE_ASPECT,
"width", actor_size,
"height", actor_size,
"content", CLUTTER_CONTENT (icon),
@ -1037,6 +1038,7 @@ st_texture_cache_load_gicon (StTextureCache *cache,
g_free (gicon_string);
actor = create_invisible_actor ();
clutter_actor_set_content_gravity (actor, CLUTTER_CONTENT_GRAVITY_RESIZE_ASPECT);
clutter_actor_set_size (actor, actor_size, actor_size);
if (!ensure_request (cache, key, policy, &request, actor))
{