fix: 修复 SNI 懒加载托盘图标右键菜单无法显示的问题 - #1699
Conversation
部分 SNI 应用(如 Snipaste)的 DBusMenu 菜单采用懒加载:右键菜单先以空状态(无菜单项、surface 极小/空白)创建并显示,AboutToShow 调用返回后内容才异步到达、surface 尺寸随之变化,但弹窗不会重新布局/绘制,内容始终无法显示。 修复:在 TrayItemSurfacePopup(常规托盘区)、SurfacePopup(stashed收纳托盘区)和 SurfaceSubPopup(子菜单)中监听菜单 surface 的宽高变化,内容异步到达、尺寸变化时重新请求几何更新,使弹窗按新内容重新布局与绘制。 本修复需配合 dde-tray-loader 的对应修复(右击托盘图标时主动触发 DBus AboutToShow 拉取懒加载菜单内容),确保菜单内容能被拉取到。
|
[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. 😃 |
|
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. |
Reviewer's GuideThis PR fixes DBusMenu lazy-loading tray menu visibility issues by watching menu surface size changes and requesting geometry updates when content arrives asynchronously for main tray, stashed tray, and submenu popups. Sequence diagram for lazy-loaded DBusMenu tray popup geometry updatesequenceDiagram
actor User
participant dde_tray_loader
participant DBusMenuApp
participant menuSurfaceLayer
participant menuWindow
User->>dde_tray_loader: rightClickTrayIcon
dde_tray_loader->>DBusMenuApp: AboutToShow
DBusMenuApp->>menuSurfaceLayer: createEmptyMenuSurface
menuSurfaceLayer-->>menuWindow: showInitialPopup
DBusMenuApp-->>menuSurfaceLayer: asyncPopulateMenuContent
menuSurfaceLayer-->>menuSurfaceLayer: onWidthChanged
menuSurfaceLayer-->>menuWindow: requestUpdateGeometry
menuSurfaceLayer-->>menuSurfaceLayer: onHeightChanged
menuSurfaceLayer-->>menuWindow: requestUpdateGeometry
menuWindow-->>User: popupRelayoutWithVisibleMenu
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The new width/height Connections blocks are duplicated across three QML files; consider extracting a small reusable helper/component to handle surface size changes and geometry updates to keep the behavior consistent and easier to maintain.
- For each Connections element, consider guarding against a null/undefined target (e.g., when menuSurfaceLayer/popupSurfaceLayer/popupMenuContent are not yet initialized) to avoid QML runtime warnings or unexpected behavior.
- Calling requestUpdateGeometry on every width/height change may be more frequent than necessary; if the surfaces emit multiple size changes during layout, you might want to coalesce or debounce updates, or only trigger when the menu actually finishes loading.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new width/height Connections blocks are duplicated across three QML files; consider extracting a small reusable helper/component to handle surface size changes and geometry updates to keep the behavior consistent and easier to maintain.
- For each Connections element, consider guarding against a null/undefined target (e.g., when menuSurfaceLayer/popupSurfaceLayer/popupMenuContent are not yet initialized) to avoid QML runtime warnings or unexpected behavior.
- Calling requestUpdateGeometry on every width/height change may be more frequent than necessary; if the surfaces emit multiple size changes during layout, you might want to coalesce or debounce updates, or only trigger when the menu actually finishes loading.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
dde-tray-loader侧合并请求:linuxdeepin/dde-tray-loader#494 |
部分 SNI 应用(如 Snipaste)的 DBusMenu 菜单采用懒加载:右键菜单先以空状态(无菜单项、surface 极小/空白)创建并显示,AboutToShow 调用返回后内容才异步到达、surface 尺寸随之变化,但弹窗不会重新布局/绘制,内容始终无法显示。
修复:在 TrayItemSurfacePopup(常规托盘区)、SurfacePopup(stashed收纳托盘区)和 SurfaceSubPopup(子菜单)中监听菜单 surface 的宽高变化,内容异步到达、尺寸变化时重新请求几何更新,使弹窗按新内容重新布局与绘制。
本修复需配合 dde-tray-loader 的对应修复(右击托盘图标时主动触发 DBus AboutToShow 拉取懒加载菜单内容),确保菜单内容能被拉取到。
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
Ensure tray popup menus correctly re-layout when lazily loaded DBusMenu content updates their surface size.
Bug Fixes: