Skip to content

feat(plugin-display): migrate treeland output protocol v1 to v2 - #3483

Draft
deepin-wm wants to merge 1 commit into
linuxdeepin:masterfrom
deepin-wm:treeland-output-v2-migration
Draft

deepin-wm wants to merge 1 commit into
linuxdeepin:masterfrom
deepin-wm:treeland-output-v2-migration

Conversation

@deepin-wm

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

Copy link
Copy Markdown

概述

将 dde-control-center 中 treeland output v1 协议消费者迁移到 v2,参照 dde-shell 的迁移方式。

Ref: DDE-233

变更内容

src/plugin-display/CMakeLists.txt

  • find_package(TreelandProtocols REQUIRED)find_package(TreelandProtocols 0.6 REQUIRED)
  • XML 引用 treeland-output-manager-v1.xmltreeland-output-manager-unstable-v2.xml

src/plugin-display/wayland/client/TreeLandOutputManager.h

  • include qwayland-treeland-output-manager-v1.hqwayland-treeland-output-manager-unstable-v2.h
  • 基类 treeland_output_manager_v1treeland_output_manager_v2
  • treeland_output_color_control_v1treeland_output_picture_control_v2
  • setPrimaryOutput(const char *)setPrimaryOutput(struct wl_output *)
  • getColorControlgetPictureControl
  • primary_output 事件 override 签名从 (const QString &)(struct wl_output *)
  • 新增 primary_output_failed 事件 override

src/plugin-display/wayland/client/TreeLandOutputManager.cpp

  • 全部 treeland_output_*_v1:: 调用更名
  • get_color_controlget_picture_control
  • set_primary_output 参数从 string 改为 wl_output *
  • primary_output 事件:从 wl_output * 反查 QScreen → 名称(处理 null 情况)
  • result 事件参数从 success(1/0)改为 result(commit_result 枚举)
  • 接口版本从 2 重置为 1(v2 是新接口)
  • 新增 primary_output_failed 事件处理(日志告警)

src/plugin-display/wayland/client/WayQtUtils.h / .cpp

  • 新增 qScreenFromWlOutput(wl_output *) 辅助函数,用于 wl_output *QScreen * 反查

src/plugin-display/operation/private/displayworker.cpp

  • setPrimary:按名称查找 QScreenwl_output * 后调用 setPrimaryOutput
  • updateControlgetColorControlgetPictureControl

协议 v1→v2 关键变更对照

v1 v2
treeland_output_manager_v1 treeland_output_manager_v2
treeland_output_color_control_v1 treeland_output_picture_control_v2
get_color_control(output) get_picture_control(output)
set_primary_output(string name) set_primary_output(struct wl_output*)
primary_output(string name) 事件 primary_output(struct wl_output*) 事件(allow-null)
result(uint success) 事件 result(uint result) 事件 + commit_result 枚举
primary_output_failed 事件(新增)

约束

  • 构建依赖 treeland-protocols ≥ 0.6
  • 此 PR 为 draft,待人工审核,不要合并

Summary by Sourcery

Migrate Treeland output management in the display plugin to protocol v2 while preserving primary-output and picture-control functionality.

Enhancements:

  • Migrate the display plugin’s Treeland output integration from protocol v1 to unstable v2, including picture-control access and wl_output-based primary-output handling.
  • Resolve Wayland outputs back to Qt screens and handle primary-output failures and nullable output events.
  • Clamp brightness and color-temperature requests to protocol-supported ranges before submission.

Build:

  • Require treeland-protocols 0.6 or newer and generate the client from the unstable Treeland output manager v2 protocol.

@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

Migrates the Treeland output protocol consumer from v1 to unstable v2, including generated bindings, wl_output-based primary-output operations and events, picture-control acquisition, and the required TreelandProtocols 0.6 dependency while preserving the display worker’s screen-name API.

Sequence diagram for v2 primary output selection

sequenceDiagram
    participant DisplayWorker
    participant ScreenMap
    participant TreeLandOutputManager
    participant Treeland

    DisplayWorker->>ScreenMap: find screen by name
    ScreenMap-->>DisplayWorker: wl_output*
    DisplayWorker->>TreeLandOutputManager: setPrimaryOutput(wl_output*)
    TreeLandOutputManager->>Treeland: set_primary_output(wl_output*)
    alt primary output accepted
        Treeland-->>TreeLandOutputManager: primary_output(wl_output*)
        TreeLandOutputManager->>TreeLandOutputManager: qScreenFromWlOutput(wl_output*)
        TreeLandOutputManager-->>DisplayWorker: primaryOutputChanged(name)
    else primary output rejected
        Treeland-->>TreeLandOutputManager: primary_output_failed(error)
    end
Loading

Sequence diagram for v2 picture control acquisition

sequenceDiagram
    participant DisplayWorker
    participant TreeLandOutputManager
    participant Treeland
    participant PictureControl

    DisplayWorker->>TreeLandOutputManager: getPictureControl(wl_output*)
    TreeLandOutputManager->>TreeLandOutputManager: isOutputAlive(wl_output*)
    TreeLandOutputManager->>Treeland: get_picture_control(wl_output*)
    Treeland-->>TreeLandOutputManager: picture_control_v2
    TreeLandOutputManager-->>DisplayWorker: ColorControl
    DisplayWorker->>PictureControl: setBrightness(value)
    PictureControl->>Treeland: set_brightness(value)
    PictureControl->>Treeland: commit()
    Treeland-->>PictureControl: result(result)
Loading

Flow diagram for wl_output and QScreen conversion

flowchart LR
    A[QScreen name] --> B[wlOutputFromQScreen]
    B --> C[wl_output*]
    C --> D[set_primary_output]
    D --> E[primary_output wl_output*]
    E --> F[qScreenFromWlOutput]
    F --> G[primaryOutputChanged name]
Loading

File-Level Changes

Change Details Files
Migrate the generated Wayland client bindings and build dependency from Treeland output manager v1 to unstable v2.
  • Require TreelandProtocols 0.6 or newer.
  • Generate and include the unstable v2 output-manager protocol bindings.
  • Update manager and picture-control inheritance, method calls, event handlers, and destruction for v2 semantics.
  • Reset the advertised client extension version to 1 for the new protocol interface.
src/plugin-display/CMakeLists.txt
src/plugin-display/wayland/client/TreeLandOutputManager.h
src/plugin-display/wayland/client/TreeLandOutputManager.cpp
Adapt primary-output handling to the v2 wl_output-based API and preserve the existing screen-name-facing behavior.
  • Resolve the requested screen name to its wl_output before issuing set_primary_output.
  • Convert primary_output wl_output events back to QScreen names, including null/unmatched output handling.
  • Log the new primary_output_failed error event.
  • Add a wl_output-to-QScreen reverse lookup utility over current Qt screens.
src/plugin-display/operation/private/displayworker.cpp
src/plugin-display/wayland/client/TreeLandOutputManager.cpp
src/plugin-display/wayland/client/WayQtUtils.h
src/plugin-display/wayland/client/WayQtUtils.cpp
Switch display control acquisition to the v2 picture-control interface.
  • Replace get_color_control with get_picture_control.
  • Retain existing ColorControl wrapper behavior over the v2 picture-control object.
src/plugin-display/operation/private/displayworker.cpp
src/plugin-display/wayland/client/TreeLandOutputManager.h
src/plugin-display/wayland/client/TreeLandOutputManager.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

Migrate the treeland output v1 protocol consumer to v2 in
dde-control-center, following the same migration pattern as dde-shell.

Key changes:
- CMakeLists.txt: require TreelandProtocols >= 0.6, reference
  treeland-output-manager-unstable-v2.xml instead of v1
- TreeLandOutputManager: rebind to treeland_output_manager_v2;
  rename color_control → picture_control interfaces and methods
  (get_color_control → get_picture_control)
- set_primary_output: parameter changed from string name to
  wl_output*; displayworker resolves monitor name → QScreen →
  wl_output via m_screen_outputs before calling
- primary_output event: now receives wl_output* (nullable) instead
  of string; reverse-lookup via new WQt::Utils::qScreenFromWlOutput
  to recover the screen name for DisplayModel::setPrimary
- result event: argument changed from uint success (1/0) to
  commit_result enum (success=0/failed=1/unsupported=2/...)
- Add primary_output_failed event handler for v2
- Interface version reset from 2 to 1 (v2 is a new interface)
- Add qScreenFromWlOutput helper to WayQtUtils for wl_output →
  QScreen reverse lookup

Ref: DDE-233
@wineee
wineee force-pushed the treeland-output-v2-migration branch from 30bbde9 to e5133b0 Compare September 10, 2026 06:09
@deepin-bot

deepin-bot Bot commented Sep 10, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 6.1.106
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #3497

@deepin-bot

deepin-bot Bot commented Sep 11, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 6.1.107
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #3503

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