Skip to content

feat(showdesktop): adapt to treeland-show-desktop-unstable-v1 protocol - #1725

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
deepin-wm:agent/dde-pl/2543570b96ce
Sep 9, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
deepin-wm:agent/dde-pl/2543570b96ce

Conversation

@deepin-wm

@deepin-wm deepin-wm commented Sep 9, 2026 •

Copy link
Copy Markdown

Summary

Adapt the dock showdesktop panel from the deprecated treeland-window-management-v1 protocol to the new treeland-show-desktop-unstable-v1 protocol.

Changes

  1. Rename treelandwindowmanager.h/.cpp → treelandshowdesktop.h/.cpp, class TreelandWindowManager → TreelandShowDesktop
  2. Protocol switch from treeland-window-management-v1.xml to treeland-show-desktop-unstable-v1.xml
  3. API updates: set_desktop() → set_show_desktop_state(), callback treeland_window_management_v1_show_desktop → treeland_show_desktop_v1_show_desktop_state, enums desktop_state_normal/show → state_normal/show
  4. Caller updates in showdesktop.h/.cpp: include, member type, and method calls
  5. Build dep bump: treeland-protocols (>> 0.5.7) → >> 0.5.9 in debian/control
  6. CMake version gate: find_package(TreelandProtocols 0.6.0 REQUIRED)

Related

Multica issue: DDE-228

Summary by Sourcery

Migrate the dock show-desktop panel from the deprecated window-management protocol to the Treeland show-desktop protocol.

Enhancements:

  • Migrate the dock show-desktop integration to the Treeland show-desktop protocol, including updated state handling and client integration.

Build:

  • Require TreelandProtocols 0.6.0 and generate the client from the treeland-show-desktop-unstable-v1 protocol definition.

Chores:

  • Rename the Treeland show-desktop client implementation to reflect its protocol role and update the package dependency requirement.

@deepin-ci-robot

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@sourcery-ai

sourcery-ai Bot commented Sep 9, 2026

Copy link
Copy Markdown

Reviewer's Guide

Migrates the dock show-desktop panel from the deprecated treeland-window-management-v1 client to treeland-show-desktop-unstable-v1, including regenerated build inputs, renamed client wrapper, updated state-toggle API, applet integration, and raised protocol package requirements.

Sequence diagram for the show-desktop state toggle

sequenceDiagram
    participant User
    participant ShowDesktop
    participant TreelandShowDesktop
    participant TreelandCompositor

    User->>ShowDesktop: toggleShowDesktop()
    ShowDesktop->>TreelandShowDesktop: desktopToggle()
    TreelandShowDesktop->>TreelandShowDesktop: set_show_desktop_state(state_show or state_normal)
    TreelandCompositor-->>TreelandShowDesktop: treeland_show_desktop_v1_show_desktop_state(state)
    TreelandShowDesktop->>TreelandShowDesktop: update m_desktopState
Loading

File-Level Changes

Change Details Files
Replaces the deprecated window-management client with the new show-desktop Wayland protocol.
  • Renames the wrapper class and source/header files.
  • Generates and includes bindings from the show-desktop protocol XML.
  • Updates the protocol method, callback, and state enum usage.
  • Tracks the compositor-reported desktop state and toggles between normal and show states when active.
panels/dock/showdesktop/treelandshowdesktop.cpp
panels/dock/showdesktop/treelandshowdesktop.h
panels/dock/showdesktop/treelandwindowmanager.cpp
panels/dock/showdesktop/treelandwindowmanager.h
panels/dock/showdesktop/CMakeLists.txt
Integrates the renamed protocol client into the show-desktop applet.
  • Updates includes, member type, initialization, and toggle calls to use TreelandShowDesktop.
  • Preserves the non-Wayland fallback behavior when no protocol client is created.
panels/dock/showdesktop/showdesktop.cpp
panels/dock/showdesktop/showdesktop.h
Raises protocol dependency requirements to ensure the new interface is available.
  • Requires TreelandProtocols 0.6.0 in CMake.
  • Bumps the Debian build dependency from versions above 0.5.7 to above 0.5.9.
panels/dock/showdesktop/CMakeLists.txt
debian/control

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

@wineee
wineee marked this pull request as ready for review September 9, 2026 05:42

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

Sorry @wineee, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 1 hour and 8 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

Comment thread panels/dock/showdesktop/treelandshowdesktop.cpp Outdated
@deepin-wm
deepin-wm force-pushed the agent/dde-pl/2543570b96ce branch from 5ee25d6 to 87390f6 Compare September 9, 2026 05:53
@deepin-wm
deepin-wm marked this pull request as draft September 9, 2026 05:53
@wineee
wineee marked this pull request as ready for review September 9, 2026 06:01

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

Sorry @wineee, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 48 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, deepin-wm

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

deepin pr auto review

🤖 AI 代码审查报告

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

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 总体评分 100 分,大于 70 分通过阈值,代码质量符合要求。本次提交将 showdesktop 模块从 treeland-window-management-v1 协议迁移至 treeland-show-desktop-unstable-v1 协议,代码结构清晰,逻辑正确,无安全漏洞。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

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

建议: 语法正确,逻辑清晰。代码从旧协议到新协议的迁移保持了完整的逻辑一致性:构造函数正确初始化 m_desktopState 为 state_normal,desktopToggle() 正确实现了状态切换逻辑(state_show 与 state_normal 互斥切换),回调函数 treeland_show_desktop_v1_show_desktop_state() 正确处理状态同步。空指针安全:toggleShowDesktop() 中先检查 m_showDesktop 非空再调用,desktopToggle() 中先检查 isActive() 再发送协议请求。内存管理:通过 Qt 父子对象机制(setParent(parent))确保对象生命周期正确管理,无内存泄漏。


2. 代码质量 ✅

评价: 优秀 ✅ 通过

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

建议: 代码结构清晰,注释完整。SPDX 版权头已更新为 2023-2026 年份范围。新增文件 treelandshowdesktop.cpp/h 遵循与原 treelandwindowmanager.cpp/h 完全一致的代码结构和风格。类命名 TreelandShowDesktop 清晰反映新协议名称。CMakeLists.txt 正确更新了源文件列表、协议 XML 文件路径和版本要求。debian/control 中构建依赖版本从 0.5.7 提升至 0.5.9,与新协议版本匹配。无重复代码、无调试代码残留。


3. 代码性能 ✅

评价: 优秀 ✅ 通过

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

建议: 性能良好,资源使用合理。所有操作均为 O(1) 时间复杂度。desktopToggle() 仅在 isActive() 为真时发送一次 Wayland 协议请求,无冗余操作。状态回调函数仅在做实际状态变更时更新成员变量,避免不必要的写操作。非 Wayland 平台下正确回退至 QProcess::startDetached 执行桌面切换命令,不影响原有性能。


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

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

建议: 存在0个安全漏洞。本次代码变更不涉及用户输入处理、文件操作、网络通信或命令拼接,不存在命令注入、路径遍历、缓冲区溢出等安全风险。QProcess::startDetached 使用硬编码路径 /usr/lib/deepin-daemon/desktop-toggle 且无用户可控参数,安全可控。Wayland 协议通信为本地 IPC,状态参数为 uint32_t 类型,无越界风险。


💡 改进建议代码示例

// 本次代码变更质量优秀,无需修复示例。
// 迁移后的 TreelandShowDesktop 类保持了与原 TreelandWindowManager 一致的安全模式:

class TreelandShowDesktop : public QWaylandClientExtensionTemplate<TreelandShowDesktop>,
                           public QtWayland::treeland_show_desktop_v1
{
public:
    explicit TreelandShowDesktop(QObject *parent)
        : QWaylandClientExtensionTemplate<TreelandShowDesktop>(
              treeland_show_desktop_v1_interface.version)
        , m_desktopState(state_normal)
    {
        setParent(parent);  // Qt 父子对象管理,确保无内存泄漏
    }

    void desktopToggle()
    {
        if (isActive()) {  // 安全检查:确认 Wayland 连接活跃
            set_show_desktop_state(
                m_desktopState == state_show ? state_normal : state_show);
        }
    }

protected:
    void treeland_show_desktop_v1_show_desktop_state(uint32_t state) override
    {
        if (state != m_desktopState) {  // 避免冗余更新
            m_desktopState = state;
        }
    }

private:
    uint32_t m_desktopState;
};

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

1. Rename treelandwindowmanager to treelandshowdesktop, update class name TreelandWindowManager to TreelandShowDesktop
2. Switch wayland protocol from treeland-window-management-v1 to treeland-show-desktop-unstable-v1
3. Update API calls: set_desktop to set_show_desktop_state, update callback and enum names
4. Bump treeland-protocols build-dep to >> 0.5.9 in debian/control
5. Add CMake version requirement find_package(TreelandProtocols 0.6.0 REQUIRED)

Influence:
1. Test show desktop toggle on Wayland: click dock show desktop button, verify show and restore work correctly
2. Verify non-Wayland fallback path (QProcess desktop-toggle) is unaffected
3. Full build with treeland-protocols >= 0.6.0 passes

feat: 适配 showdesktop 至 show-desktop-v1 协议

1. 重命名 treelandwindowmanager 为 treelandshowdesktop,更新类名 TreelandWindowManager 为 TreelandShowDesktop
2. 切换 Wayland 协议从 treeland-window-management-v1 到 treeland-show-desktop-unstable-v1
3. 更新 API 调用:set_desktop 变为 set_show_desktop_state,更新回调和枚举名
4. 在 debian/control 中提升 treeland-protocols 构建依赖到 >> 0.5.9
5. 添加 CMake 版本要求 find_package(TreelandProtocols 0.6.0 REQUIRED)

Influence:
1. 在 Wayland 下测试显示桌面切换:点击任务栏显示桌面按钮,验证显示和恢复正常
2. 验证非 Wayland 回退路径(QProcess desktop-toggle)不受影响
3. 使用 treeland-protocols >= 0.6.0 进行完整构建
@18202781743
18202781743 force-pushed the agent/dde-pl/2543570b96ce branch from 87390f6 to d442f3b Compare September 9, 2026 09:16
@18202781743

Copy link
Copy Markdown
Contributor

/forcemerge

@deepin-bot

deepin-bot Bot commented Sep 9, 2026

Copy link
Copy Markdown

This pr force merged! (status: blocked)

@deepin-bot
deepin-bot Bot merged commit 8077ead into linuxdeepin:master Sep 9, 2026
6 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.

5 participants