Skip to content

Tray: icons in the right-click menu - #844

Open
mgth wants to merge 1 commit into
v6from
feat/tray-menu-icons
Open

mgth wants to merge 1 commit into
v6from
feat/tray-menu-icons

Conversation

@mgth

@mgth mgth commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

The maintainer asked: « ajouter des icônes au menu clique droit dans la zone de notif ».

What each entry shows

Entry Linux (DBusMenu) Windows (item bitmap)
Open icon-data: the logo (lbm_logo.svg, 32 px PNG) the logo
Start icon-name media-playback-start the UI's Start.svg
Stop icon-name media-playback-stop the UI's Stop.svg
Refresh icon-name view-refresh the UI's Refresh.svg
Exit icon-name application-exit icons/menu/Exit.svg, drawn after lbm-ui's Icon::Power (the UI had no exit pictogram)
  • Linux: theme names from the freedesktop Icon Naming Spec, so the entries follow KDE's light or dark theme. The UI's SVGs are black where they mean "the foreground", which a dark menu would swallow (Refresh and Exit would disappear). Only Open, which has no standard name, goes as a PNG; its colours read on both backgrounds. An entry with a name carries no PNG, so no host can prefer our black over its theme.
  • Windows: MENUITEMINFOW.hbmpItem, a 32-bit top-down DIB with the colours premultiplied by alpha (what AlphaBlend reads in a themed menu), at the SM_CXSMICON size of the moment (PNGs at 16/20/24/32/40/48 px, the next size up). The bitmaps are made when the menu opens and freed after DestroyMenu: a menu does not own its items' bitmaps, and the DPI may have changed since the last opening. The menu is the light Win32 one (the agent does not opt into dark menus), hence the black pictograms there.
  • The PNGs are rendered by icons/render.sh (extended), like the tray icons.

Tests

  • icons: every menu icon decoded at every size, the colours match the UI's pictograms, the theme names table, at_least (size choice), premultiplied_bgra (byte order, rounding, never a colour above its alpha).
  • tray: one icon per entry; the Linux menu carries the theme names and the logo's PNG.
  • tray::windows: every menu icon makes a DIB and it is freed (runs in the Windows CI job).
  • cargo clippy --workspace --all-targets -D warnings clean on Linux and x86_64-pc-windows-gnu; cargo fmt --check clean.

Seen

  • Linux (KDE Plasma Wayland, dark theme): a throwaway agent (--fake-hook, its own XDG_RUNTIME_DIR, config and data) published the menu. GetLayout over D-Bus shows the names and the PNG, and a real right-click displayed the five icons: Breeze's icons in white, the logo in colour.
  • Windows 11 (vm124, 4K): this branch's agent, app, hook, inject and service built on the VM and deployed in C:\LittleBigMouse\v6; the menu opened by the message a right-click on the icon sends (WM_APP+1, WM_RBUTTONUP) and captured: the five pictograms on the light menu, edges blended, no black boxes. The menu then closed on WM_CANCELMODE, nothing chosen.

🤖 Generated with Claude Code

Open, Start, Stop, Refresh and Exit each show a pictogram, the UI's own for the same
thing (Start.svg, Stop.svg, Refresh.svg, the logo for Open) plus an Exit drawn after
lbm-ui's Icon::Power, the UI having none.

Linux: DBusMenu's icon-name with the Icon Naming Spec names (media-playback-start,
media-playback-stop, view-refresh, application-exit), so the entries follow KDE's light
or dark theme; the UI's pictograms are black where they mean "the foreground" and would
vanish in a dark menu. Open carries the logo as icon-data (PNG), readable on both.

Windows: an item bitmap per entry (MENUITEMINFO.hbmpItem), a 32-bit DIB premultiplied
by its alpha, at the small-icon size of the moment (SM_CXSMICON), made when the menu
opens and freed once it is gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@mgth mgth left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Les 23 tests ciblés des icônes et du menu passent sous Linux. Il reste un cas Windows à corriger pour les configurations où les écrans ont des facteurs d’échelle différents.

fn menu(window: HWND) {
// SAFETY: a popup menu owned here, destroyed below.
// SAFETY: a metrics query.
let size = unsafe { GetSystemMetrics(SM_CXSMICON) }.max(16) as u32;

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dimensionner les pictogrammes pour l’écran qui affiche le menu. L’agent est déclaré compatible DPI par moniteur, mais GetSystemMetrics(SM_CXSMICON) renvoie une métrique système. Si l’écran principal est à 100 % et que le menu s’ouvre sur un écran à 200 %, le code peut choisir le bitmap de 16 px pour un emplacement de 32 px. Récupérer la position utilisée par TrackPopupMenu avant de créer les bitmaps, puis appeler GetSystemMetricsForDpi avec le DPI de l’écran correspondant permettrait de choisir la bonne taille à chaque ouverture. Documentation Win32

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recontrôlé sur 888ad02b. Le menu choisit toujours la taille du bitmap avec GetSystemMetrics(SM_CXSMICON) avant de lire la position du curseur. Le correctif pour les écrans à échelles différentes reste attendu.

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.

1 participant