fix(status-area): constrain menu icon-data to icon size

Menu items expose their icon as a themed `icon-name` or raw PNG `icon-data`. The named-icon branch renders at a fixed `.size(14)`, but the icon-data branch wrapped the pixmap in a bare `Image` with no size constraint, so it rendered at the PNG's native dimensions. Apps may send full-resolution pixmaps, which then render oversized in the menu.

Constrain icon-data to the same 14px box with ContentFit::Contain, matching how KDE (Qt small-icon size) and GNOME (St.Icon popup-menu-icon) render menu item icons.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Rafael Kraut 2026-07-06 15:41:53 +02:00 • committed by Michael Murphy
parent ec8ffdc85d
commit 63292ab74d

View file

@ -232,7 +232,11 @@ fn layout_view(layout: &Layout, expanded: Option<i32>) -> cosmic::Element<'_, Ms
}
if let Some(icon_data) = i.icon_data() {
let handle = iced::widget::image::Handle::from_bytes(icon_data.to_vec());
children.insert(0, iced::widget::Image::new(handle).into());
let icon = iced::widget::Image::new(handle)
.width(iced::Length::Fixed(14.0))
.height(iced::Length::Fixed(14.0))
.content_fit(iced::core::ContentFit::Contain);
children.insert(0, icon.into());
} else if let Some(icon_name) = i.icon_name() {
let icon = cosmic::widget::icon::from_name(icon_name)
.size(14)