From 569f40de9bf31d67a1c7f733146d2ab7ae7d6326 Mon Sep 17 00:00:00 2001 From: Louis des Landes Date: Thu, 9 Jan 2020 16:59:45 +1030 Subject: [PATCH] Keep aspect ratio when scaling tray icons. --- src/modules/sni/item.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/modules/sni/item.cpp b/src/modules/sni/item.cpp index bcc66e22..b298e442 100644 --- a/src/modules/sni/item.cpp +++ b/src/modules/sni/item.cpp @@ -265,7 +265,11 @@ void Item::updateImage() { if (pixbuf->gobj() != nullptr) { // An icon specified by path and filename may be the wrong size for // the tray - pixbuf = pixbuf->scale_simple(icon_size, icon_size, Gdk::InterpType::INTERP_BILINEAR); + // Keep the aspect ratio and scale to make the height equal to icon_size + // If people have non square icons, assume they want it to grow in width not height + int width = icon_size * pixbuf->get_width() / pixbuf->get_height(); + + pixbuf = pixbuf->scale_simple(width, icon_size, Gdk::InterpType::INTERP_BILINEAR); image.set(pixbuf); } } else {