Tray menu: more room between item labels and the submenu chevron #3
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
In the tray menu, container/project items sit right up against the submenu chevron; it's a bit too cozy.
The menu is drawn by the desktop's tray host over DBusMenu (
ksni,src/tray.rs), so first find out what the app can control (label padding, a trailing spacer, item properties) versus what the host decides. Pick the least hacky fix that looks right on KDE Plasma and doesn't look wrong on other hosts.Done when there's visible breathing room before the chevron, with before/after screenshots in the PR, or a short write-up of why it can't be done from the app.
Posted by Upper Wolfjaw for Nye, whose token can't comment here.
Research: room before the submenu chevron (Nye)
Short version: Krane can't set spacing. The tray host draws the menu. The fix that works on every host is to pad submenu labels with trailing spaces. I measured it on Qt/Breeze and GTK3, and the exact change is below.
What the app controls
type,label,enabled,visible,icon-name,icon-data,shortcut,toggle-type,toggle-state,children-display,dispositionandaccessible-desc. None of them sets width, padding or spacing (libdbusmenu constants).labelthrough unchanged (src/menu.rs, no trimming).What the hosts draw
QMenuwithaction->setText(label). The only change it makes is_→&, and it doesn't trim (dbusmenuimporter.cpp). Breeze sizes the column from the widest label and puts the arrow in a 20px box right after it (MenuButton_IndicatorWidth20,MenuItem_ItemSpacing2 in breezemetrics.h). I measured the gap on the widest item at 16px, which is why it feels cozy. Shorter labels have plenty of room.GtkMenu(sn-item.c, Waybar item.cpp). Adwaita puts the arrow 10px after the label (menu menuitem arrow { margin-left: 10px }, gtk-contained.css). The theme decides that gap.PopupSubMenuMenuItems (dbusMenu.js). These are inline expanders whose arrow is pinned to the right edge of the whole menu. Labels aren't trimmed, and it strips only the first_.Measured: do trailing spaces count?
I checked this on Qt 6.8.2 (PyQt6, Breeze and Fusion styles) and GTK 3.24 on this Debian box. The test is one submenu item labelled
postgres-database:Both toolkits count trailing whitespace. NBSP and em space are no better than plain spaces, and em space is inconsistent on GTK. On a Krane-like menu in Breeze, 4 trailing spaces take the label→chevron gap from 16px to 31px (screenshot attached).
Recommended fix
Pad the three
SubMenulabels insrc/tray.rs(Stopped · N, compose project, container) and leaveStandardItems alone:Then use
label: submenu_label(format!("Stopped · {}", total - running_count)),label: submenu_label(project)andlabel: submenu_label(name). This is a 14+/3− patch. It's on my local branchnye/tray-chevron-spacing(ab8db56), and @UpperWolfjaw has the patch file. I haven't compiled it here yet because Qt dev isn't installed, but rustfmt parses it.Where it could look off
Noticed while here (separate)
Labels go through mnemonic handling on every host (
_→&in Qt, first_dropped on GNOME). A container or project namedmy_appwill likely show asmyappwith an underlineda. Escaping withlabel.replace('_', "__")insubmenu_labeland theheader_itemimage/id labels would fix that. I haven't verified it on a live host yet, so it's worth a quick look when this lands.