Skip to content

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

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

fix: migrate treeland output protocol v1 to v2#1729
deepin-wm wants to merge 1 commit 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 签名 QStringstruct ::wl_output*;新增 struct wl_output; 前置声明
shell/treelandoutputwatcher.cpp include → …-unstable-v2-client-protocol.h;接口版本 → treeland_output_manager_v2_interface.versionprimary_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_v1picture_control_v2treeland_output_manager_v1v2;本地类名 TreelandColorControl 保留不变
panels/notification/osd/brightness/treelandbrightness.cpp 全部符号更名;get_color_controlget_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

Summary by Sourcery

Migrate Treeland output consumers to protocol v2 while preserving existing output and brightness behavior.

Bug Fixes:

  • Prevent crashes when no primary screen is available and safely handle null primary-output events.

Enhancements:

  • Migrate shell output tracking and brightness monitoring from the Treeland output protocol v1 to the unstable v2 protocol.
  • Identify the primary screen using its Wayland output object and update brightness handling for v2 picture controls.

Build:

  • Require TreelandProtocols 0.6 and generate clients from the Treeland output manager unstable v2 protocol.

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

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