Skip to content

fix: resolve show-desktop panel flicker and state desync - #1762

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
wjyrich:agent/pms-bug-bot/4a1e6f786c39
Oct 14, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
wjyrich:agent/pms-bug-bot/4a1e6f786c39

Conversation

@wjyrich

@wjyrich wjyrich commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Root Cause Analysis

When triggering "Show Desktop" with a dock plugin panel (quick-settings, network, calendar, etc.) open, the panel flickers once before disappearing. The root cause is twofold:

  1. Panel flicker: showdesktop.qml's onClicked handler calls Applet.toggleShowDesktop() without first closing the active popup via Panel.requestClosePopup(). Since the popup is a transient child of the dock panel window, treeland briefly toggles its visibility during show-desktop processing, causing the flicker. All other dock interaction paths (blank-area click, position change, context menu) already call Panel.requestClosePopup() — this path was missed.

  2. State desync: desktopToggle() in treelandshowdesktop.cpp used m_desktopState (updated by compositor callbacks) to decide toggle direction. When no windows are on the desktop, the compositor-reported state can desync from the user's intended state, causing the first toggle to have no effect and requiring a second toggle.

Fix

  1. Added Panel.requestClosePopup() before Applet.toggleShowDesktop() in showdesktop.qml's onClicked, consistent with all other dock interaction paths.
  2. Introduced m_requestedState member variable in TreelandShowDesktop to track the user's intended state. desktopToggle() now bases its toggle direction on m_requestedState instead of m_desktopState, which is still updated by compositor callbacks but no longer affects toggle decisions.

Change Safety Assessment

Code Safety

  • Risk Level: Low
  • The changes are minimal: one QML line addition and one C++ member variable with a modified toggle condition. No function signatures changed, no public API affected.
  • m_desktopState is still maintained by compositor callbacks for state reporting; only the toggle decision logic shifted to m_requestedState, preserving existing behavior for external observers.

Business Impact Scope

  • Dock show-desktop button: The primary affected feature — clicking the show-desktop button in the dock.
  • Plugin panels (popup windows): Quick-settings, network, calendar, and other dock plugin panels that are open when show-desktop is triggered.
  • Show-desktop toggle behavior: Repeated toggling of show-desktop, especially in no-window scenarios.

Verification Suggestion

  1. Open any dock plugin panel, then trigger show-desktop — verify the panel disappears immediately without flickering.
  2. With no windows on the desktop, trigger show-desktop repeatedly — verify each toggle responds correctly without missed responses.

根因分析

在打开任务栏插件面板(快捷设置、网络、日历等)时触发"显示桌面",面板会先闪现一次再消失。根因有两个方面:

  1. 面板闪现:showdesktop.qml 的 onClicked 处理器在调用 Applet.toggleShowDesktop() 前未通过 Panel.requestClosePopup() 关闭当前弹窗。由于弹窗是 dock 面板窗口的 transient 子窗口,treeland 在处理显示桌面时会短暂改变其可见性,导致闪现。其他所有 dock 交互路径(空白区域点击、位置变化、右键菜单)都已调用 Panel.requestClosePopup(),此路径遗漏了。

  2. 状态失步:treelandshowdesktop.cpp 的 desktopToggle() 使用合成器回调更新的 m_desktopState 决定切换方向。当桌面上无窗口时,合成器报告的状态可能与用户意图不同步,导致第一次切换无效果,需要再次切换。

修复方案

  1. 在 showdesktop.qml 的 onClicked 中调用 Applet.toggleShowDesktop() 前添加 Panel.requestClosePopup(),与其他 dock 交互路径保持一致。
  2. 在 TreelandShowDesktop 中新增 m_requestedState 成员变量追踪用户意图状态。desktopToggle() 基于 m_requestedState 而非 m_desktopState 决定切换方向,m_desktopState 仍由合成器回调更新但不影响切换决策。

改动安全评估

代码安全评估

  • 风险等级:低风险
  • 改动极小:QML 添加一行调用,C++ 新增一个成员变量并修改切换条件。无函数签名变更,无公开 API 影响。
  • m_desktopState 仍由合成器回调维护用于状态报告,仅切换决策逻辑转移到 m_requestedState,对外部观察者保持既有行为。

业务影响范围

  • 任务栏显示桌面按钮:主要受影响功能——点击任务栏的显示桌面按钮。
  • 插件面板(弹窗):快捷设置、网络、日历等 dock 插件面板在触发显示桌面时的行为。
  • 显示桌面切换行为:重复切换显示桌面,尤其在无窗口场景下的响应。

验证建议

  1. 打开任意 dock 插件面板后触发显示桌面——验证面板立即消失,无闪现。
  2. 桌面上无窗口时连续触发显示桌面——验证每次切换都正确响应,无漏响应。

PMS: BUG-379453

Summary by Sourcery

Bug Fixes:

  • Prevent dock plugin panels from flickering when Show Desktop is triggered by closing active popups first.

@sourcery-ai

sourcery-ai Bot commented Oct 14, 2026

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

Reviewer's Guide

The change fixes Show Desktop flicker by explicitly closing active dock popups first, and prevents toggle desynchronization by tracking the requested state independently from compositor callbacks. Review the popup lifecycle interaction and repeated-toggle behavior, especially when no windows are present.

Sequence diagram for flicker-free Show Desktop activation

sequenceDiagram
    actor User
    participant ShowDesktop as showdesktop.qml
    participant Panel
    participant Applet
    participant Compositor

    User->>ShowDesktop: onClicked
    ShowDesktop->>Panel: requestClosePopup()
    Panel-->>ShowDesktop: Popup closed
    ShowDesktop->>Applet: toggleShowDesktop()
    Applet->>Compositor: set_show_desktop_state(requestedState)
    Compositor-->>Applet: Apply Show Desktop state
Loading

File-Level Changes

Change Details Files
Closes active dock popups before initiating Show Desktop to prevent transient panel flicker.
  • Requests popup closure in the show-desktop button click handler before toggling desktop visibility.
panels/dock/showdesktop/package/showdesktop.qml
Separates the user-requested toggle state from compositor-reported state so repeated toggles remain consistent.
  • Adds and initializes a requested-state member.
  • Updates the requested state and sends it to the compositor for each toggle while retaining the compositor state for reporting.
panels/dock/showdesktop/treelandshowdesktop.cpp
panels/dock/showdesktop/treelandshowdesktop.h

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 found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="panels/dock/showdesktop/treelandshowdesktop.cpp" line_range="21" />
<code_context>
 {
     if (isActive()) {
-        set_show_desktop_state(m_desktopState == state_show ? state_normal : state_show);
+        m_requestedState = (m_requestedState == state_show) ? state_normal : state_show;
+        set_show_desktop_state(m_requestedState);
     }
</code_context>
<issue_to_address>
**First click repeats active state**

When the compositor is already showing the desktop at startup or another actor changes its state, `m_requestedState` remains `state_normal` because compositor updates change only `m_desktopState`; `desktopToggle()` therefore sends `state_show` again instead of restoring the windows, and the dock button appears unresponsive.

Base the toggle on the compositor-reported `m_desktopState` (or keep `m_requestedState` synchronized with it) before sending the request.

Also at `panels/dock/showdesktop/treelandshowdesktop.cpp:13`.
</issue_to_address>

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

Comment thread panels/dock/showdesktop/treelandshowdesktop.cpp Outdated
Root cause: showdesktop.qml onClicked handler called
toggleShowDesktop() without first closing the active popup,
causing treeland to briefly toggle popup visibility during
show-desktop processing, resulting in a visible flicker.

Fix: add Panel.requestClosePopup() before toggleShowDesktop()
call, consistent with all other dock interaction paths.

Log: Fixed panel flicker when triggering show-desktop with plugin panels open

Influence:
1. Test show-desktop with quick-settings/network/calendar panel open
2. Verify no regression on normal show-desktop with windows present

PMS: BUG-379453
@wjyrich
wjyrich force-pushed the agent/pms-bug-bot/4a1e6f786c39 branch from 02a6d6a to 96ed243 Compare October 14, 2026 02:46
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: BLumia, wjyrich

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

@wjyrich

wjyrich commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Oct 14, 2026

Copy link
Copy Markdown

This pr force merged! (status: blocked)

@deepin-bot
deepin-bot Bot merged commit f6363e5 into linuxdeepin:master Oct 14, 2026
7 of 10 checks passed
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