From 5062c4c9c2c960bf8edf70aa95dc6fca53088f03 Mon Sep 17 00:00:00 2001 From: Sebastian Keller Date: Wed, 10 Mar 2021 17:27:42 +0100 Subject: [PATCH] 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: --- src/st/st-texture-cache.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/st/st-texture-cache.c b/src/st/st-texture-cache.c index 0ed3df5e7..178acbb5d 100644 --- a/src/st/st-texture-cache.c +++ b/src/st/st-texture-cache.c @@ -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)) {