Skip to content

fix(tray): create the dbus menu once the probe succeeds - #5293

Open
Motaphe wants to merge 1 commit into
Alexays:masterfrom
Motaphe:fix/5285-tray-menu-precreate
Open

fix(tray): create the dbus menu once the probe succeeds#5293
Motaphe wants to merge 1 commit into
Alexays:masterfrom
Motaphe:fix/5285-tray-menu-precreate

Conversation

@Motaphe

@Motaphe Motaphe commented Sep 1, 2026

Copy link
Copy Markdown

What does this PR do?

Tray context menus open empty on the first click and only work on the second.

b58018b swapped the makeMenu() call in the Menu property handler for an async probe, but menuProbeReady() never calls makeMenu(). handleClick() is now the only call site, so the menu gets created and popped in the same block. Dbusmenu loads its layout asynchronously, so the first click gets a menu with no root item yet:

LIBDBUSMENU-GLIB-CRITICAL: dbusmenu_menuitem_send_about_to_show: assertion 'DBUSMENU_IS_MENUITEM(mi)' failed
*** BUG *** In pixman_region32_init_rect: Invalid rectangle passed

That empty menu is the small blank popup users see. The second click works because the layout has arrived.

It is a re-regression of 01ad3d9 ("fix(tray): pre-create dbusmenu for tray items", 2019), which fixed the same assertion by creating the menu at property-set time.

Calling makeMenu() when the probe succeeds restores that timing. Items that do not export com.canonical.dbusmenu still fail the probe and still fall back to ContextMenu.

The diff is @awsms's from #5285, credited in the commit. They also suggested reverting b58018b outright. I have no strong view, happy to switch this to a revert if you prefer.

Related issues

Closes #5285

Checklist

  • Code is formatted with clang-format
  • Builds locally (ninja -C build)
  • Man page updated. Not applicable, no user-facing option changed.
  • Tested against the affected module(s)

Testing

Hyprland, three SNI items (KDE Connect, Nextcloud, an Electron app).

Before: empty popup on the first click, full menu on the second, with the two log lines above.
After: full menu on the first click, log clean.

b58018b swapped the makeMenu() call in the "Menu" property handler for
an async probe, but menuProbeReady() never calls makeMenu(). That leaves
handleClick() as the only call site, so the menu is created and popped in
the same block. Dbusmenu loads its layout asynchronously, so the first
click gets a menu with no root item yet and logs:

  LIBDBUSMENU-GLIB-CRITICAL: dbusmenu_menuitem_send_about_to_show:
  assertion 'DBUSMENU_IS_MENUITEM(mi)' failed

GTK then builds a degenerate popup, which pixman reports as
"In pixman_region32_init_rect: Invalid rectangle passed". The second
click works because the layout has arrived by then.

This is a re-regression of 01ad3d9 ("fix(tray): pre-create dbusmenu for
tray items"), which fixed the same assertion the same way.

Items that do not export com.canonical.dbusmenu still fail the probe and
still fall back to ContextMenu, so the intent of b58018b is kept.

Closes Alexays#5285

Co-authored-by: awsms <48278661+awsms@users.noreply.github.com>
@etherb0x

etherb0x commented Sep 2, 2026

Copy link
Copy Markdown

Experienced this myself just now, and it looks like a few people have hit the same path and had Claude or somesuch land on the same fix.

Apps I saw the slow (empty-then-populated) right-click menu on: fcitx5, qpwgraph, SVP Manager, which all use a Qt /MenuBar dbusmenu.

Build is Waybar v0.15.0-1004-g6d60c8e0 (master).

@bokicoder

Copy link
Copy Markdown

They also suggested reverting b58018b outright. I have no strong view, happy to switch this to a revert if you prefer.

This really needs to be reverted. It also causes blueman‑tray's right‑click menu to fail to show up, an issue this PR does not resolve. blueman‑tray is likely not the only affected tray application; other tray programs may be broken in the same way.

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.

Context menu in tray module renders empty on first click, works normally on second click

3 participants