Skip to content

fix(dock): close popup proactively when showing desktop - #1742

Closed
mhduiy wants to merge 1 commit into
linuxdeepin:masterfrom
mhduiy:agent/pms-bug-bot/b6a9ba6e7ac7
Closed

mhduiy wants to merge 1 commit into
linuxdeepin:masterfrom
mhduiy:agent/pms-bug-bot/b6a9ba6e7ac7

Conversation

@mhduiy

@mhduiy mhduiy commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

修复:显示桌面时主动关闭任务栏插件面板(闪现问题)

问题

当桌面上有应用窗口置顶时,用户打开任务栏插件面板(popup)后触发"显示桌面"功能,popup 会闪现一次再消失。

根因

treeland_show_desktop_v1_show_desktop_state() 回调仅更新内部状态 m_desktopState,不 emit 任何信号,导致 dock 面板无法在 treeland 窗口重排前主动关闭 popup。popup 只能被动通过焦点丢失关闭,与 treeland 窗口重排存在时序窗口,产生闪现。

修复方案

在 TreelandShowDesktop 类中新增 showDesktopStateChanged 信号,通过 ShowDesktop::desktopShownChanged 转发,在 main.qml 中监听该信号并在显示桌面时主动调用 Panel.requestClosePopup() 关闭所有 popup。

改动文件

  • panels/dock/showdesktop/treelandshowdesktop.h — 新增 Q_SIGNALS,声明 showDesktopStateChanged(bool shown)
  • panels/dock/showdesktop/treelandshowdesktop.cpp — 状态变更后 Q_EMIT showDesktopStateChanged(state == state_show)
  • panels/dock/showdesktop/showdesktop.h — 新增 desktopShownChanged(bool shown) 信号
  • panels/dock/showdesktop/showdesktop.cpp — init() 中 connect 转发信号
  • panels/dock/package/main.qml — 监听 desktopShownChanged,主动关闭 popup

安全评估

纯增量改动,不修改任何现有函数签名或调用路径,回归风险低。

PMS Bug: https://pms.uniontech.com/bug-view-360895.html

Summary by Sourcery

Prevent dock popup flicker by notifying the UI when the desktop is shown and closing active popups immediately.

Bug Fixes:

  • Close dock popups proactively when the desktop is shown to prevent them from briefly reappearing during window rearrangement.

Enhancements:

  • Propagate show-desktop state changes from the Wayland integration to the dock applet and QML UI.

When triggering "show desktop" while a dock popup is open, the popup
was only closed passively via focus loss after treeland rearranged
windows, causing a brief flash. The root cause is that
treeland_show_desktop_v1_show_desktop_state() only updated internal
state without emitting a signal, so the dock panel had no way to
proactively close popups before the window rearrangement.

Add showDesktopStateChanged signal to TreelandShowDesktop, forward it
via ShowDesktop::desktopShownChanged, and listen for it in main.qml to
call Panel.requestClosePopup() when the desktop is shown.

Log: Fix popup flash when showing desktop with dock popup open
Bug: https://pms.uniontech.com/bug-view-360895.html
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mhduiy

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

@sourcery-ai

sourcery-ai Bot commented Sep 14, 2026

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

Reviewer's Guide

The change exposes Treeland’s show-desktop state as a signal and forwards it to QML, allowing the dock to close all popups immediately when showing the desktop and preventing a transient popup flash during window reordering.

Sequence diagram for proactive popup closure when showing desktop

sequenceDiagram
    participant Treeland
    participant TreelandShowDesktop
    participant ShowDesktop
    participant QML
    participant Panel

    Treeland->>TreelandShowDesktop: treeland_show_desktop_v1_show_desktop_state(state)
    TreelandShowDesktop->>TreelandShowDesktop: update m_desktopState
    TreelandShowDesktop-->>ShowDesktop: showDesktopStateChanged(true)
    ShowDesktop-->>QML: desktopShownChanged(true)
    QML->>Panel: requestClosePopup()
Loading

File-Level Changes

Change Details Files
Propagate Treeland show-desktop state changes through the dock applet.
  • Declare a state-change signal on the Wayland client wrapper.
  • Emit the signal only when the compositor-reported state changes.
  • Forward the wrapper signal from the applet during Wayland initialization.
panels/dock/showdesktop/treelandshowdesktop.h
panels/dock/showdesktop/treelandshowdesktop.cpp
panels/dock/showdesktop/showdesktop.h
panels/dock/showdesktop/showdesktop.cpp
Close dock popups proactively when the desktop becomes visible.
  • Listen for the applet’s desktop visibility signal in QML.
  • Request popup closure when the signal indicates the desktop is shown.
panels/dock/package/main.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 reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 98 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 总体评分 98 分,大于 70 分通过阈值,代码质量符合要求。本次变更实现了显示桌面时主动关闭 dock 弹出窗口的功能,通过建立 Wayland 协议回调到 QML 的完整信号链路实现,代码结构清晰,逻辑正确,无安全漏洞。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 语法正确,逻辑清晰,信号链路设计合理,无需修改


2. 代码质量 ✅

评价: 优秀 ✅ 通过

潜在问题:

  1. panels/dock/showdesktop/showdesktop.h:43 - 新增信号 desktopShownChanged(bool shown) 缺少文档注释,建议说明信号触发条件
  2. panels/dock/showdesktop/treelandshowdesktop.h:23 - 新增信号 showDesktopStateChanged(bool shown) 缺少文档注释,建议说明信号触发条件

建议: 建议为新增的信号添加简要文档注释,说明信号的触发条件和参数含义,提升代码可维护性


3. 代码性能 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 性能良好,Qt 信号/槽机制在同线程下为直接调用,开销极小;状态变更守卫(state != m_desktopState)避免了冗余信号发射


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: 无安全风险,代码不涉及用户输入处理、文件操作、网络操作、命令执行等安全敏感场景。Wayland 协议状态值来自受信任的合成器(compositor)


💡 改进建议代码示例

// showdesktop.h - 建议添加注释
Q_SIGNALS:
    void visibleChanged();
    /// \brief 当桌面显示状态变化时发出此信号
    /// \param shown true 表示桌面正在显示,false 表示取消显示桌面
    void desktopShownChanged(bool shown);

// treelandshowdesktop.h - 建议添加注释
Q_SIGNALS:
    /// \brief 当 Wayland 协议报告桌面状态变化时发出此信号
    /// \param shown true 表示桌面正在显示,false 表示取消显示桌面
    void showDesktopStateChanged(bool shown);

本报告由 AI 代码审查工具自动生成

@xionglinlin

Copy link
Copy Markdown
Contributor

此pr为multica提交的,分析不合理,且此问题已经修复了。故关闭此pr

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.

3 participants