Skip to content

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

Open
RafaelKr wants to merge 1 commit into
pop-os:masterfrom
RafaelKr:fix/status-area-menu-icon-size
Open

fix(status-area): constrain menu icon-data to icon size#1466
RafaelKr wants to merge 1 commit into
pop-os:masterfrom
RafaelKr:fix/status-area-menu-icon-size

Conversation

@RafaelKr

@RafaelKr RafaelKr commented Jul 6, 2026

Copy link
Copy Markdown

Fixes #1147

Menu-item icon-data (raw PNG) rendered at its native size, unlike the icon-name branch which uses .size(14), so apps sending full-resolution pixmaps show oversized icons in the menu.

Spec: com.canonical.dbusmenu defines icon-data only as "PNG data of the icon." — no size, no aspect ratio. It is an item icon just like icon-name, only delivered as raw bytes. Reference DEs render both sources at the same fixed menu-icon size:

  • KDE (libdbusmenuqt, dbusmenuimporter.cpp): icon-nameQIcon::fromTheme and icon-dataQIcon(pixmap) both become a plain QIcon on the same QAction; QMenu then draws every action icon at QStyle::PM_SmallIconSize.
  • GNOME (AppIndicator, dbusMenu.js): _updateImage() assigns icon-name and icon-data to the same St.Icon (popup-menu-icon), which has one fixed size.

This applet's icon-name branch already does the same (.size(14)); this change renders icon-data in that same 14px box (ContentFit::Contain).

Alternatives considered — for non-square icons (square icons render 14×14 either way):

  • height: 14, variable width: fills the row height, but the icon column then varies in width, so labels stop aligning with icon-name rows.
  • height: 14, min-width: 14: would restore that alignment, but iced exposes no min_width on image/container — and even with it, a genuinely wide icon would still exceed 14px and misalign its row.

Both alternatives keep a non-square (variable-width) slot, which also deviates from KDE/GNOME (fixed square slot). The chosen fixed 14×14 box keeps every icon row aligned (aspect preserved via Contain) and matches their square slot.

Repro: NetBird's tray menu (0.74.2) ships a 256×256 logo. Note: NetBird 0.75.0 (will be released very soon) is a full UI rework and may not reproduce this.

#1147 has screenshots of the current state (before this fix) and KDE. This fix sizes menu item icons correctly:
Screenshot_2026-07-06_15-36-09

  • I have disclosed use of any AI generated code in my commit messages.
    • If you are using an LLM, and do not fully understand the changes it is making to the code base, do not create a PR.
    • In our experience, AI generated code often results in overly complex code that lacks enough context for a proper fix or feature inclusion. This results in considerably longer code reviews. Due to this, AI authored or partially authored PRs may be closed without comment.
  • I understand these changes in full and will be able to respond to review comments.
  • My change is accurately described in the commit message.
  • My contribution is tested and working as described.
  • I have read the Developer Certificate of Origin and certify my contribution under its conditions.

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>
@RafaelKr
RafaelKr force-pushed the fix/status-area-menu-icon-size branch from 7b24325 to 6b925b7 Compare July 7, 2026 07:15
@tobyrg

tobyrg commented Jul 30, 2026

Copy link
Copy Markdown

Any chance this could get a look?

@mmstick
mmstick requested review from a team July 31, 2026 02:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Status Area] NetBird status menu is broken

3 participants