Skip to content

fix: migrate treeland output protocol v1 to v2 - #1729

Draft
deepin-wm wants to merge 5 commits into
linuxdeepin:masterfrom
deepin-wm:agent/bot/9cda2caa2af3
Draft

deepin-wm wants to merge 5 commits into
linuxdeepin:masterfrom
deepin-wm:agent/bot/9cda2caa2af3

Conversation

@deepin-wm

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

Copy link
Copy Markdown

Treeland output 协议 v2 适配

将 dde-shell 中两处 treeland output v1 协议消费者迁移到 v2(纯协议消费者迁移,无逻辑变更)。

改动文件(6 个)

文件 改动
shell/CMakeLists.txt find_package(TreelandProtocols 0.6 REQUIRED);XML 引用 → treeland-output-manager-unstable-v2.xml
shell/treelandoutputwatcher.h include → qwayland-treeland-output-manager-unstable-v2.h;基类 → treeland_output_manager_v2;override 签名 QString → struct ::wl_output*;新增 struct wl_output; 前置声明
shell/treelandoutputwatcher.cpp include → …-unstable-v2-client-protocol.h;接口版本 → treeland_output_manager_v2_interface.version;primary_output 改为 null 早返回 + 遍历 qApp->screens() 通过 QNativeInterface::QWaylandScreen::output() 反查 QScreen
panels/notification/osd/brightness/CMakeLists.txt 同上版本约束 + XML 引用(保留 NO_INCLUDE_CORE_ONLY)
panels/notification/osd/brightness/treelandbrightness.h 全部符号 color_control_v1 → picture_control_v2;treeland_output_manager_v1 → v2;本地类名 TreelandColorControl 保留不变
panels/notification/osd/brightness/treelandbrightness.cpp 全部符号更名;get_color_control → get_picture_control;接口版本更新

关键说明

  • 构建依赖:treeland-protocols ≥ 0.6(v2 XML 由 master 提供,尚未发 tag)
  • 无 #include <QNativeInterface>:Qt6 不为该命名空间生成转发头文件,QWaylandScreen 通过 <QScreen> 传递性引入
  • null 处理:v2 primary_output 事件 allow-null="true",实现中 null 早返回
  • 顺带修复:v1 代码 qApp->primaryScreen()->name() 在 primaryScreen() 返回 null 时会崩溃;v2 版本增加了 null 防护

Ref: DDE-232
Multica Issue: DDE-541

Summary by Sourcery

Migrate Treeland output consumers to protocol v2 and resolve outputs by UUID for reliable primary-screen and brightness tracking.

New Features:

  • Migrate shell output tracking and brightness OSD consumers to Treeland output manager protocol v2 with UUID-based output identification.
  • Add handling for output UUID resolution and v2 brightness picture-control results, including invalid-output recovery.

Bug Fixes:

  • Prevent primary-screen handling from failing when no primary output is available and defer updates until matching screens are ready.

Enhancements:

  • Require Treeland protocols 0.8 and generate clients for the unstable output manager v2 and output UUID protocols.

@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

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 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

@sourcery-ai

sourcery-ai Bot commented Sep 9, 2026

Copy link
Copy Markdown

Reviewer's Guide

Updates both Treeland output protocol consumers to unstable v2, including build-time protocol generation and generated Qt Wayland bindings. The shell now resolves nullable wl_output events back to QScreen objects, while the brightness OSD uses the renamed v2 picture-control interface; application logic is otherwise preserved, with added null safety for missing primary outputs.

Sequence diagram for v2 primary output resolution

sequenceDiagram
    participant Compositor
    participant TreelandOutputWatcher
    participant QGuiApplication
    participant QScreen
    participant QWindowSystemInterface
    Compositor->>TreelandOutputWatcher: treeland_output_manager_v2_primary_output(output)
    alt output is null
        TreelandOutputWatcher-->>Compositor: return
    else output is valid
        TreelandOutputWatcher->>QGuiApplication: screens()
        loop each screen
            TreelandOutputWatcher->>QScreen: nativeInterface<QNativeInterface::QWaylandScreen>()
            TreelandOutputWatcher->>QScreen: output()
            alt output matches
                TreelandOutputWatcher->>QWindowSystemInterface: handlePrimaryScreenChanged(screen->handle())
                TreelandOutputWatcher-->>Compositor: return
            end
        end
    end
Loading

File-Level Changes

Change Details Files
Migrates the shell output watcher from the v1 name-based event to the v2 wl_output-based event and updates generated protocol integration.
  • Requires TreelandProtocols 0.6 and generates clients from the unstable v2 XML.
  • Binds the v2 manager interface and handles nullable primary_output events.
  • Maps the event’s wl_output to a QScreen through QWaylandScreen before notifying Qt of the primary-screen change.
shell/CMakeLists.txt
shell/treelandoutputwatcher.h
shell/treelandoutputwatcher.cpp
Migrates the brightness OSD provider from v1 color-control symbols to the v2 picture-control API without changing its read-only behavior.
  • Requires TreelandProtocols 0.6 and generates the v2 protocol client while retaining NO_INCLUDE_CORE_ONLY.
  • Updates manager/control base classes, callback names, object types, and interface version.
  • Uses get_picture_control to obtain the v2 control for the selected output.
panels/notification/osd/brightness/CMakeLists.txt
panels/notification/osd/brightness/treelandbrightness.h
panels/notification/osd/brightness/treelandbrightness.cpp

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

@deepin-bot

deepin-bot Bot commented Sep 10, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 2.0.54
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1733

@deepin-bot

deepin-bot Bot commented Sep 22, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 2.0.55
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1752

@deepin-bot

deepin-bot Bot commented Sep 23, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 2.0.56
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1753

@deepin-bot

deepin-bot Bot commented Oct 12, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 2.0.57
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1758

@deepin-bot

deepin-bot Bot commented Oct 15, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 2.0.58
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1765

@deepin-bot

deepin-bot Bot commented Oct 16, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 2.0.59
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1766

@deepin-bot

deepin-bot Bot commented Oct 20, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 2.0.60
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1773

@deepin-bot

deepin-bot Bot commented Oct 28, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 2.0.61
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1786

wineee and others added 2 commits November 3, 2026 09:43
1. Update find_package to require TreelandProtocols 0.6 in both CMakeLists
2. Migrate treelandoutputwatcher to treeland_output_manager_v2 with wl_output
3. Migrate treelandbrightness from color_control_v1 to picture_control_v2
4. Handle null primary_output with early return for v2 allow-null

Log: Migrated treeland output protocol consumers from v1 to v2

Influence:
1. Test primary screen switching in multi-monitor setups
2. Verify OSD brightness display reflects correct values
3. Test dde-shell does not crash when no output is available

fix: 迁移 treeland output 协议 v1 到 v2

1. 更新两处 CMakeLists 的 find_package 要求 TreelandProtocols 0.6
2. 迁移 treelandoutputwatcher 至 treeland_output_manager_v2 使用 wl_output
3. 迁移 treelandbrightness 从 color_control_v1 到 picture_control_v2
4. 处理 null primary_output 提前返回以适配 v2 allow-null 语义

Log: 迁移 treeland output 协议消费者从 v1 到 v2

Influence:
1. 测试多屏环境下主屏切换功能
2. 验证 OSD 亮度显示反映正确数值
3. 测试无输出设备时 dde-shell 不崩溃

Ref: DDE-232
Update SPDX-FileCopyrightText year to 2024-2026 for the files modified
by the treeland output protocol v1 to v2 migration, as required by the
license check workflow.
@deepin-wm
deepin-wm force-pushed the agent/bot/9cda2caa2af3 branch from da82ef5 to e375c85 Compare November 3, 2026 01:44
1. Update find_package to require TreelandProtocols 0.8 in both CMakeLists
2. Add treeland-output-uuid-unstable-v1.xml protocol dependency for UUID mapping
3. Change primary_output event callback from wl_output* to const QString &uuid
4. Change get_picture_control request from wl_output* to const QString &uuid
5. Add TreelandOutputUuidManager and TreelandOutputUuid for wl_output→uuid mapping
6. Replace pointer comparison with UUID mapping table lookup for primary screen
7. Add result event handling with commit_result enum (invalid_output=3)
8. Add primary_output_failed event handling
9. Cache pending primary uuid for timing when primary_output arrives before uuid map
10. Fix duplicate SPDX-FileCopyrightText lines in treelandoutputwatcher files

Log: Adapted treeland output protocol v2 consumers from wl_output* to UUID strings

Influence:
1. Test primary screen switching in multi-monitor setups
2. Verify OSD brightness display reflects correct values
3. Test dde-shell does not crash when no output is available

fix: 适配 treeland output 协议 v2 为基于 UUID 的标识方式

1. 更新两处 CMakeLists 的 find_package 要求 TreelandProtocols 0.8
2. 新增 treeland-output-uuid-unstable-v1.xml 协议依赖用于 UUID 映射
3. primary_output 事件回调从 wl_output* 改为 const QString &uuid
4. get_picture_control 请求从 wl_output* 改为 const QString &uuid
5. 新增 TreelandOutputUuidManager 和 TreelandOutputUuid 建立 wl_output→uuid 映射
6. 主屏匹配方式从指针比较改为 UUID 映射表查找
7. 补充 result 事件处理,含 commit_result 枚举(invalid_output=3)
8. 补充 primary_output_failed 事件处理
9. 缓存 pending primary uuid 处理 primary_output 早于 uuid 映射的时序问题
10. 修复 treelandoutputwatcher 文件中重复的 SPDX-FileCopyrightText 行

Log: 适配 treeland output 协议 v2 消费者从 wl_output* 到 UUID 字符串

Influence:
1. 测试多屏环境下主屏切换功能
2. 验证 OSD 亮度显示反映正确数值
3. 测试无输出设备时 dde-shell 不崩溃

Ref: DDE-232
1. Add onScreenRemoved slot connected to QGuiApplication::screenRemoved
2. Clean up m_uuidToScreen and m_uuidRequests entries when a screen is removed
3. Prevent use-after-free when applyPrimary dereferences a destroyed QScreen*
4. Call deleteLater() on TreelandOutputUuid after receiving UUID, consistent with TreelandBrightness

Log: Fixed use-after-free risk on screen hot-unplug and wayland resource leak in TreelandOutputUuid

Influence:
1. Test screen hot-plug/unplug scenarios in multi-monitor setups
2. Verify primary screen switching does not crash after screen removal

fix: 处理屏幕移除并修复 TreelandOutputUuid 生命周期

1. 新增 onScreenRemoved 槽函数,连接 QGuiApplication::screenRemoved 信号
2. 屏幕移除时清除 m_uuidToScreen 和 m_uuidRequests 中对应条目
3. 防止 applyPrimary 解引用已销毁的 QScreen* 导致 use-after-free 崩溃
4. 收到 UUID 后调用 deleteLater() 释放 TreelandOutputUuid 对象,与 TreelandBrightness 保持一致

Log: 修复屏幕热插拔移除时的 use-after-free 风险及 TreelandOutputUuid 的 wayland 资源泄漏

Influence:
1. 测试多屏环境下屏幕热插拔/热移除场景
2. 验证屏幕移除后主屏切换不会崩溃

Ref: DDE-541
- Update debian/control Build-Depends from treeland-protocols (>= 0.7.0) to (>= 0.8.0)
- Aligns with find_package(TreelandProtocols 0.8 REQUIRED) in CMakeLists.txt
- 更新 debian/control 构建依赖 treeland-protocols 从 0.7.0 到 0.8.0
- 与 CMakeLists.txt 中 find_package(TreelandProtocols 0.8 REQUIRED) 保持一致
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