Skip to content

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

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

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

Conversation

@hotime

@hotime hotime commented Aug 13, 2026

Copy link
Copy Markdown

部分 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:

  • Fix SNI tray icon context menus that stay blank by requesting geometry updates when menu surfaces change size.
  • Fix stashed tray area popups and submenu popups so lazily loaded menu items become visible after asynchronous content arrival.

部分 SNI 应用(如 Snipaste)的 DBusMenu 菜单采用懒加载:右键菜单先以空状态(无菜单项、surface 极小/空白)创建并显示,AboutToShow 调用返回后内容才异步到达、surface 尺寸随之变化,但弹窗不会重新布局/绘制,内容始终无法显示。

修复:在 TrayItemSurfacePopup(常规托盘区)、SurfacePopup(stashed收纳托盘区)和 SurfaceSubPopup(子菜单)中监听菜单 surface 的宽高变化,内容异步到达、尺寸变化时重新请求几何更新,使弹窗按新内容重新布局与绘制。

本修复需配合 dde-tray-loader 的对应修复(右击托盘图标时主动触发 DBus AboutToShow 拉取懒加载菜单内容),确保菜单内容能被拉取到。
@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. 😃

@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 commented Aug 13, 2026

Copy link
Copy Markdown

Reviewer's Guide

This 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 update

sequenceDiagram
    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
Loading

File-Level Changes

Change Details Files
Trigger geometry updates when the main tray surface popup menu’s content causes its surface size to change asynchronously.
  • Add a Connections block bound to menuSurfaceLayer to listen for width and height changes.
  • Gate the connections behind menu.readyBinding and menu.menuVisible so geometry updates only occur for a ready, visible menu.
  • On width or height change, call menu.menuWindow.requestUpdateGeometry() to relayout/redraw the popup.
panels/dock/tray/SurfacePopup.qml
Ensure submenu popups relayout when their surface size changes due to lazy-loaded menu content.
  • Add a Connections block bound to popupSurfaceLayer to listen for width and height changes.
  • Enable the connections only when popup.readyBinding and popup.menuVisible are true.
  • Invoke popup.menuWindow.requestUpdateGeometry() on width/height change to update submenu geometry.
panels/dock/tray/SurfaceSubPopup.qml
Make tray item surface popups update geometry when their menu surface size changes after lazy-loaded content is fetched.
  • Add a nested Connections block inside the existing popupMenu content Item, targeting popupMenuContent.
  • Conditionally enable the connections with popupMenu.readyBinding and popupMenu.menuVisible.
  • On width or height change, call popupMenu.menuWindow.requestUpdateGeometry() so the popup resizes and redraws to fit new content.
panels/dock/tray/TrayItemSurfacePopup.qml

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

@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:

  • 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.

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-tray-loader侧合并请求:linuxdeepin/dde-tray-loader#494

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