mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
Merge pull request #548 from Psykar/icon-width
Keep aspect ratio when scaling tray icons.
This commit is contained in:
commit
b9cd51a9cc
@ -265,7 +265,11 @@ void Item::updateImage() {
|
|||||||
if (pixbuf->gobj() != nullptr) {
|
if (pixbuf->gobj() != nullptr) {
|
||||||
// An icon specified by path and filename may be the wrong size for
|
// An icon specified by path and filename may be the wrong size for
|
||||||
// the tray
|
// 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);
|
image.set(pixbuf);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user