Skip to content

fix: 修复 SNI 懒加载托盘图标右键菜单无法显示的问题 - #494

Open
hotime wants to merge 1 commit into
linuxdeepin:masterfrom
hotime:fix/sni-menu-abouttoshow
Open

fix: 修复 SNI 懒加载托盘图标右键菜单无法显示的问题#494
hotime wants to merge 1 commit into
linuxdeepin:masterfrom
hotime:fix/sni-menu-abouttoshow

Conversation

@hotime

@hotime hotime commented Aug 13, 2026

Copy link
Copy Markdown

部分 SNI 应用(如 Snipaste)的 DBusMenu 菜单采用懒加载:只有收到 AboutToShow 调用后才填充菜单内容。此前右击托盘图标时从未触发 DBus AboutToShow,右键菜单始终无法显示内容。

修复:右击分支在显示菜单前主动调用 updateMenu(menu) 触发一次 DBus AboutToShow,拉取懒加载菜单内容。

本修复需配合 dde-shell 的对应修复(监听菜单 surface 尺寸变化并重新请求几何更新),使内容异步到达时弹窗能重新布局与绘制。

AI辅助声明:本修复方案由deepseek-v4-flash协助生成,并已在本地完成实际测试验证。

Snipaste下载地址:https://zh.snipaste.com/download.html
测试使用的Snipaste版本:https://download.snipaste.com/archives/Snipaste-2.11.3-x86_64.AppImage

Summary by Sourcery

Bug Fixes:

  • Fix missing right-click tray menu contents for SNI applications that lazily populate DBusMenu on AboutToShow.

部分 SNI 应用(如 Snipaste)的 DBusMenu 菜单采用懒加载:只有收到 AboutToShow 调用后才填充菜单内容。此前右击托盘图标时从未触发 DBus AboutToShow,右键菜单始终无法显示内容。
    
修复:右击分支在显示菜单前主动调用 updateMenu(menu) 触发一次 DBus AboutToShow,拉取懒加载菜单内容。
    
本修复需配合 dde-shell 的对应修复(监听菜单 surface 尺寸变化并重新请求几何更新),使内容异步到达时弹窗能重新布局与绘制。
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: hotime

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@deepin-ci-robot

Copy link
Copy Markdown

Hi @hotime. Thanks for your PR. 😃

@sourcery-ai

sourcery-ai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR ensures that DBusMenu-based SNI tray icons with lazy-loaded menus (e.g., Snipaste) correctly populate and display their right-click menus by proactively triggering a DBus AboutToShow via updateMenu() before showing the menu.

Sequence diagram for lazy-loaded SNI tray menu right-click handling

sequenceDiagram
    actor User
    participant SniTrayProtocolHandler
    participant MenuImporter
    participant DBusMenu
    participant SNIApp

    User->>SniTrayProtocolHandler: eventFilter(QEventContextMenu)
    SniTrayProtocolHandler->>MenuImporter: menuImporter()
    MenuImporter-->>SniTrayProtocolHandler: menu
    SniTrayProtocolHandler->>MenuImporter: updateMenu(menu)
    MenuImporter->>DBusMenu: AboutToShow
    DBusMenu->>SNIApp: AboutToShow
    SNIApp-->>DBusMenu: populate_menu_items
    DBusMenu-->>MenuImporter: updated_menu
    SniTrayProtocolHandler->>DBusMenu: setFixedSize(sizeHint)
    SniTrayProtocolHandler->>User: show populated context menu
Loading

File-Level Changes

Change Details Files
Proactively trigger DBus AboutToShow for SNI tray menus before displaying them so lazy-loaded menus populate correctly.
  • In the right-click event handling path, obtain the DBusMenu instance from the menu importer before the menu is shown.
  • Call updateMenu(menu) on the menu importer to force a DBus AboutToShow signal and pull in lazily loaded menu content.
  • Keep the existing logic that fixes the menu size using sizeHint() and ensures the native window ID is created, so geometry and rendering continue to work as before.
plugins/application-tray/sniprotocolhandler.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot

Copy link
Copy Markdown

Hi @hotime. Thanks for your PR.

I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Consider adding a null check for menuImporter() and menu before calling updateMenu(menu) to avoid potential crashes in edge cases where the importer or menu is not available.
  • If updateMenu(menu) can be relatively expensive or trigger network/IPC calls, it may be worth restricting it to the right-click branch only and ensuring it is not called redundantly in other code paths that also show the menu.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider adding a null check for `menuImporter()` and `menu` before calling `updateMenu(menu)` to avoid potential crashes in edge cases where the importer or menu is not available.
- If `updateMenu(menu)` can be relatively expensive or trigger network/IPC calls, it may be worth restricting it to the right-click branch only and ensuring it is not called redundantly in other code paths that also show the menu.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@hotime

hotime commented Aug 13, 2026

Copy link
Copy Markdown
Author

dde-shell侧合并请求:linuxdeepin/dde-shell#1699

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants