fix: 修复 SNI 懒加载托盘图标右键菜单无法显示的问题 - #494
Conversation
部分 SNI 应用(如 Snipaste)的 DBusMenu 菜单采用懒加载:只有收到 AboutToShow 调用后才填充菜单内容。此前右击托盘图标时从未触发 DBus AboutToShow,右键菜单始终无法显示内容。
修复:右击分支在显示菜单前主动调用 updateMenu(menu) 触发一次 DBus AboutToShow,拉取懒加载菜单内容。
本修复需配合 dde-shell 的对应修复(监听菜单 surface 尺寸变化并重新请求几何更新),使内容异步到达时弹窗能重新布局与绘制。
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @hotime. Thanks for your PR. 😃 |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis 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 handlingsequenceDiagram
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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
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 Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider adding a null check for
menuImporter()andmenubefore callingupdateMenu(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.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
dde-shell侧合并请求:linuxdeepin/dde-shell#1699 |
部分 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: