Skip to content

feat(personalization): implement new protocol split for treeland-protocols 0.6.0 - #1384

Merged
zccrs merged 1 commit into
linuxdeepin:masterfrom
deepin-wm:agent/git-commit/8caa5a57575b
Sep 17, 2026
Merged

zccrs merged 1 commit into
linuxdeepin:masterfrom
deepin-wm:agent/git-commit/8caa5a57575b

Conversation

@deepin-wm

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

Copy link
Copy Markdown
Contributor

Summary

Adapt the personalization module to treeland-protocols 0.6.0 breaking changes by implementing 3 new protocol server implementations while keeping the old personalization-manager-v1 for backward compatibility during the transition period.

New protocol implementations

  1. treeland_decoration_unstable_v1 → decorationmanagerinterfacev1.{h,cpp}

    • Per-surface SSD decoration context (corner radius, shadow, border, titlebar mode)
    • Surface ownership validation on get_decoration_context
  2. treeland_appearance_unstable_v1 → appearanceinterfacev1.{h,cpp}

    • Read-only push model: all current values sent on bind, broadcasts on change
    • Handles TreelandUserConfig object replacement (reconnect signals, re-push)
  3. treeland_appearance_manager_unstable_v1 → appearancemanagerinterfacev1.{h,cpp}

    • Privileged set_* requests writing to DConfig
    • Calls Helper::syncPaletteTypeWithWindowThemeType() for color scheme changes

Shared types

  • Shadow and Border structs extracted to src/common/windowdecorations.h, shared by old and new protocol implementations.

Key design decisions

  • Old + new coexistence: Old PersonalizationManagerInterfaceV1 kept alongside new protocols; old code has zero changes (only struct extraction).
  • Push model: All get_* requests removed; values pushed on bind and on change.
  • Data conversions: activeColor string↔RGBA; windowOpacity int↔wl_fixed_t; windowThemeType↔color_scheme.

Files changed

Type File
New src/common/windowdecorations.h
New src/modules/personalization/decorationmanagerinterfacev1.{h,cpp}
New src/modules/personalization/appearanceinterfacev1.{h,cpp}
New src/modules/personalization/appearancemanagerinterfacev1.{h,cpp}
Modified src/modules/personalization/CMakeLists.txt
Modified src/modules/personalization/personalizationmanagerinterfacev1.h
Modified src/seat/helper.{h,cpp}
Modified src/CMakeLists.txt
Modified tests/test_protocol_personalization/main.cpp

Multica issue: WM-444

Summary by Sourcery

Adopt treeland-protocols 0.6.0 appearance interfaces while retaining the legacy personalization protocol for compatibility.

New Features:

  • Add read-only appearance and privileged appearance-manager Wayland protocols for synchronizing and modifying user appearance settings.
  • Provide an updated appearance example client covering the new protocol settings and push-based updates.

Bug Fixes:

  • Update theme and splash color handling to use the new light/dark window color scheme values.
  • Ensure appearance updates follow user configuration replacement and propagate current values to bound clients.

Enhancements:

  • Keep the legacy personalization protocol available for backward compatibility while sharing window decoration types with newer interfaces.
  • Refactor palette synchronization and appearance configuration conversions for treeland-protocols 0.6.0.

Build:

  • Register the new appearance module and protocol-generated sources, and update example and test targets for the new interfaces.

Documentation:

  • Document the deprecated personalization protocol and record the coverage status of the new appearance protocols.

Tests:

  • Replace the personalization protocol smoke test with appearance and appearance-manager interface creation and naming checks.

Chores:

  • Remove the obsolete window cursor example and legacy appearance client implementation.

@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

This PR migrates personalization appearance functionality to the treeland-protocols 0.6.0 split by adding read-only appearance and privileged appearance-manager server globals, wiring them to DConfig with push updates and value conversions, while preserving the legacy personalization protocol and updating splash rendering, examples, build registration, and smoke coverage.

Sequence diagram for appearance push updates

sequenceDiagram
    participant Client as AppearanceClient
    participant Appearance as AppearanceInterfaceV1
    participant Config as TreelandUserConfig

    Client->>Appearance: bind_resource
    Appearance->>Config: read appearance values
    Appearance-->>Client: push all current values
    Config-->>Appearance: appearanceChanged signal
    Appearance-->>Client: push changed value
Loading

Sequence diagram for privileged appearance updates

sequenceDiagram
    participant Control as PrivilegedClient
    participant Manager as AppearanceManagerInterfaceV1
    participant Config as TreelandUserConfig
    participant Appearance as AppearanceInterfaceV1
    participant Clients as BoundAppearanceClients
    participant Helper as Helper

    Control->>Manager: set_color_scheme(scheme)
    Manager->>Config: setWindowColorScheme(scheme)
    Manager->>Helper: syncPaletteTypeWithWindowColorScheme(scheme)
    Config-->>Appearance: windowColorSchemeChanged
    Appearance-->>Clients: send_color_scheme(scheme)
Loading

State diagram for appearance configuration replacement

stateDiagram-v2
    [*] --> ConfigConnected
    ConfigConnected --> ValuesPushed: bind_resource
    ValuesPushed --> ValuesPushed: appearance setting changed
    ValuesPushed --> ConfigReplaced: Helper.configChanged
    ConfigReplaced --> ConfigConnected: setupConfigConnections
    ConfigConnected --> ValuesPushed: sendAll to bound clients
Loading

File-Level Changes

Change Details Files
Added the new read-only appearance protocol with bind-time snapshots and change broadcasts, including reconnection when the active TreelandUserConfig object is replaced.
  • Pushes all appearance settings on bind and on configuration changes.
  • Converts DConfig values to protocol representations for color, opacity, and color scheme.
  • Reconnects configuration signals and refreshes clients after user/config replacement.
src/modules/appearance/appearanceinterfacev1.h
src/modules/appearance/appearanceinterfacev1.cpp
Added the privileged appearance-manager protocol that persists client requests to DConfig and synchronizes palette state for color-scheme changes.
  • Implements setters for cursor, fonts, icon theme, accent color, opacity, titlebar height, radius, and color scheme.
  • Validates configuration availability, initialization state, ranges, and color-scheme values.
  • Invokes palette synchronization after updating the window color scheme.
src/modules/appearance/appearancemanagerinterfacev1.h
src/modules/appearance/appearancemanagerinterfacev1.cpp
Registered the new appearance module and protocols while retaining the legacy personalization global for compatibility.
  • Attaches both new appearance interfaces during Helper initialization.
  • Requires treeland-protocols 0.6.0 for the new module.
  • Keeps the old personalization implementation and updates its theme mapping to the new color-scheme configuration.
src/modules/CMakeLists.txt
src/modules/appearance/CMakeLists.txt
src/seat/helper.h
src/seat/helper.cpp
src/modules/personalization/CMakeLists.txt
src/modules/personalization/personalizationmanagerinterfacev1.h
src/modules/personalization/personalizationmanagerinterfacev1.cpp
Extracted shared server-decoration data types for legacy and new protocol consumers.
  • Moves Shadow and Border definitions into a common header.
  • Exports the shared header with development headers.
src/common/windowdecorations.h
src/CMakeLists.txt
src/modules/personalization/personalizationmanagerinterfacev1.h
Aligned splash rendering with the new light/dark window color-scheme values.
  • Maps follow-system, light, and dark splash modes against windowColorScheme.
  • Uses the corresponding light or dark palette.
src/core/shellhandler.cpp
Replaced the legacy appearance example and smoke test with clients and tests for the split protocols.
  • Adds an observer client for pushed appearance events and a manager client for setter requests.
  • Validates creation and interface names for both new server interfaces.
  • Removes the obsolete cursor example and legacy personalization client implementation.
examples/test_window_appearance/CMakeLists.txt
examples/test_window_appearance/appearance_manager.h
examples/test_window_appearance/appearance_manager.cpp
examples/test_window_appearance/main.cpp
examples/test_window_appearance/personalization_manager.h
examples/test_window_appearance/personalization_manager.cpp
examples/CMakeLists.txt
examples/test_window_cursor/CMakeLists.txt
examples/test_window_cursor/main.cpp
examples/test_window_cursor/personalization_manager.h
examples/test_window_cursor/personalization_manager.cpp
tests/CMakeLists.txt
tests/test_protocol_appearance/CMakeLists.txt
tests/test_protocol_appearance/main.cpp
tests/test_protocol_personalization/CMakeLists.txt
tests/test_protocol_personalization/main.cpp
tests/protocols/INDEX.md
Updated user configuration metadata and related test configuration snapshots for the renamed color-scheme setting.
  • Replaces windowThemeType configuration access with windowColorScheme.
  • Updates snapshot/restore logic and palette synchronization calls.
misc/dconfig/org.deepin.dde.treeland.user.json
tests/protocols/treeland-personalization-manager-v1/setup.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: 0.10.0
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1392

@deepin-wm
deepin-wm force-pushed the agent/git-commit/8caa5a57575b branch 2 times, most recently from 759191e to c87cf8d Compare September 15, 2026 13:21
@wineee
wineee requested a lite review from Copilot September 16, 2026 01:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved initialization, protocol-scope, conversion, packaging, build, and test-coverage issues remain.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR adapts personalization for treeland-protocols 0.6.0 by adding appearance protocols, retaining the legacy interface, and updating build and test integration.

Changes:

  • Adds appearance and appearance-manager protocol servers.
  • Shares decoration types and preserves legacy protocol support.
  • Replaces legacy protocol coverage with appearance smoke tests.
File summaries
File Summary
tests/test_protocol_personalization/main.cpp Removes the legacy unit test.
tests/test_protocol_personalization/CMakeLists.txt Removes the legacy test target.
tests/test_protocol_appearance/main.cpp Adds limited appearance smoke tests.
tests/test_protocol_appearance/CMakeLists.txt Adds the appearance test target.
tests/protocols/treeland-personalization-manager-v1/treeland-personalization-manager-v1.h Removes legacy client declarations.
tests/protocols/treeland-personalization-manager-v1/treeland-personalization-manager-v1.c Removes legacy protocol client coverage.
tests/protocols/treeland-personalization-manager-v1/setup.cpp Removes the legacy fixture.
tests/protocols/treeland-personalization-manager-v1/README.md Removes legacy test documentation.
tests/protocols/treeland-personalization-manager-v1/CMakeLists.txt Removes the legacy protocol target.
tests/protocols/treeland-personalization-desktop-v1/treeland-personalization-desktop-v1.h Removes desktop test declarations.
tests/protocols/treeland-personalization-desktop-v1/treeland-personalization-desktop-v1.c Removes the desktop protocol client.
tests/protocols/treeland-personalization-desktop-v1/setup.cpp Removes the desktop fixture.
tests/protocols/treeland-personalization-desktop-v1/CMakeLists.txt Removes the desktop protocol target.
tests/protocols/CMakeLists.txt Unregisters legacy protocol tests.
tests/CMakeLists.txt Registers the appearance test.
src/seat/helper.h Declares appearance interfaces.
src/seat/helper.cpp Registers the new appearance globals.
src/modules/personalization/personalizationmanagerinterfacev1.h Uses shared decoration types.
src/modules/personalization/personalizationmanagerinterfacev1.cpp Retains and documents the legacy protocol.
src/modules/personalization/CMakeLists.txt Keeps legacy protocol generation; decoration protocol remains unimplemented.
src/modules/CMakeLists.txt Adds the appearance module.
src/modules/appearance/CMakeLists.txt Adds protocol generation and build integration; a 0.6.0 minimum is needed.
src/modules/appearance/appearancemanagerinterfacev1.h Declares appearance-manager operations.
src/modules/appearance/appearancemanagerinterfacev1.cpp Implements setters; initialization gating and fixed-point conversion need correction.
src/modules/appearance/appearanceinterfacev1.h Declares the read-only appearance interface.
src/modules/appearance/appearanceinterfacev1.cpp Implements appearance pushes and config replacement handling.
src/common/windowdecorations.h Defines shared decoration structures.
src/CMakeLists.txt Includes the shared header in the build.
Review details

Suppressed comments (3)

src/modules/appearance/appearanceinterfacev1.cpp:123

  • EN: This configChanged lambda now performs reconnection plus a resource iteration and resend, which is beyond the repository's “avoid complex lambdas” convention. Extract it into a named member slot/helper so the config-replacement lifecycle is independently testable and easier to maintain.
    中文:这个 configChanged lambda 同时负责重连、遍历资源和重新发送,已经超出仓库“避免复杂 lambda”的约定。请提取为具名成员槽函数/辅助函数,使配置替换生命周期更易测试和维护。
    connect(helper, &Helper::configChanged, this, [this] {
        setupConfigConnections();
        // Push the new config values to all already-bound clients.
        for (const auto &resource : d->server->resourceMap())
            sendAll(resource->handle);
    });

src/modules/appearance/appearancemanagerinterfacev1.cpp:150

  • wl_fixed_t has 8 fractional bits, so a common value such as 0.4 is received as 0.3984375; multiplying and truncating here stores 39 instead of the requested 40. A manager set followed by an appearance push therefore drifts for ordinary percentages. Round (and apply the protocol's range validation) before converting to the integer DConfig value.

中文:wl_fixed_t 使用 8 位小数精度,因此常见的 0.4 会以 0.3984375 接收;这里相乘后直接截断会把请求的 40 写成 39。这会导致 manager 设置后再由 appearance 推送时发生偏差。转换为 DConfig 整数前应四舍五入,并执行协议规定的范围校验。

    const int value = static_cast<int>(wl_fixed_to_double(opacity) * 100.0);

tests/CMakeLists.txt:7

  • Replacing the old test target leaves tests/protocols/INDEX.md stale: its personalization-manager row still links to a deleted README, and no appearance/decor protocol coverage is indexed. Update the protocol index when removing and adding protocol tests so the documented inventory matches CMake.

中文:替换旧测试目标后,tests/protocols/INDEX.md 已过时:其中 personalization-manager 行仍链接到已删除的 README,也没有记录 appearance/decor 协议覆盖。删除和新增协议测试时请同步更新索引,使文档清单与 CMake 保持一致。

add_subdirectory(test_protocol_appearance)
  • Files reviewed: 28/28 changed files
  • Comments generated: 6
  • Review effort level: Lite

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/modules/appearance/CMakeLists.txt Outdated
Comment thread src/modules/appearance/appearanceinterfacev1.cpp
Comment thread src/modules/appearance/appearancemanagerinterfacev1.cpp Outdated
Comment thread src/modules/personalization/CMakeLists.txt
Comment thread src/modules/personalization/personalizationmanagerinterfacev1.h
Comment thread tests/test_protocol_appearance/main.cpp
@deepin-wm
deepin-wm force-pushed the agent/git-commit/8caa5a57575b branch 2 times, most recently from 9e09ff9 to a300d44 Compare September 16, 2026 03:36
@wineee

wineee commented Sep 16, 2026

Copy link
Copy Markdown
Member

Thanks for the review! All three points have been addressed in the follow-up code:

  1. Complex configChanged lambda (appearanceinterfacev1.cpp): extracted into the named member slot AppearanceInterfaceV1::onConfigChanged(), with an added null-Helper guard for unit tests and a skip-push path when the new config hasn't finished initializing.

  2. wl_fixed_t truncation (appearancemanagerinterfacev1.cpp): set_window_opacity now validates the range [0.0, 1.0] (out-of-range is logged and ignored) and converts with std::lround(value * 100.0) instead of truncating, so e.g. 0.4 correctly stores 40.

  3. Stale tests/protocols/INDEX.md: the index has been updated — legacy personalization rows removed/adjusted and new treeland-appearance-unstable-v1 / treeland-appearance-manager-unstable-v1 entries added, matching the CMake test inventory.

Note: the decoration protocol (treeland-decoration-unstable-v1) mentioned in the original split is intentionally deferred for now (src/modules/personalization/CMakeLists.txt marks it as not yet implemented).

@wineee
wineee force-pushed the agent/git-commit/8caa5a57575b branch from a300d44 to c0e0ba4 Compare September 16, 2026 06:18
@deepin-wm
deepin-wm force-pushed the agent/git-commit/8caa5a57575b branch 2 times, most recently from 9f1a6f8 to 37cd09c Compare September 16, 2026 07:01
@wineee
wineee force-pushed the agent/git-commit/8caa5a57575b branch 2 times, most recently from 02d0f3b to bb8bf70 Compare September 16, 2026 08:39
Implement treeland_appearance_unstable_v1 and
treeland_appearance_manager_unstable_v1 protocols for
treeland-protocols 0.6.0. Move appearance code to
src/modules/appearance/. Freeze old personalization module
with DEPRECATED comments. Remove personalization tests,
add appearance tests (8 tests).

为 treeland-protocols 0.6.0 实现 appearance 和
appearance-manager 两个新协议,将代码迁移到
src/modules/appearance/ 目录。冻结旧 personalization
模块并添加 DEPRECATED 注释。删除 personalization 测试,
新增 appearance 单元测试(8 项全部通过)。

Log: 实现新协议拆分,适配 treeland-protocols 0.6.0
Influence: 新增 2 个 appearance 协议实现,旧 personalization 协议冻结保留,不影响现有功能。

PMS: TASK-395091
@wineee
wineee force-pushed the agent/git-commit/8caa5a57575b branch from bb8bf70 to b2067b3 Compare September 16, 2026 09:42
@wineee
wineee marked this pull request as ready for review September 16, 2026 09:45

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

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

## Individual Comments

### Comment 1
<location path="src/modules/personalization/CMakeLists.txt" line_range="8" />
<code_context>
+# has been split into separate protocols in treeland-protocols 0.6.0:
+#   - treeland-appearance-unstable-v1        → src/modules/appearance/
+#   - treeland-appearance-manager-unstable-v1 → src/modules/appearance/
+#   - treeland-decoration-unstable-v1        → (not yet implemented)
+#
+# No new features will be added here. New code should use the new modules.
</code_context>
<issue_to_address>
**issue (broader_impact):** The advertised `treeland-decoration-unstable-v1` server implementation is absent: the build file explicitly records it as “not yet implemented” and never generates, compiles, or registers a decoration global. Clients requiring the new decoration protocol cannot bind it.

**Suggested fix:** Add the decoration protocol generation and `DecorationManagerInterfaceV1` implementation, then attach it from `Helper::init()`.
</issue_to_address>

### Comment 2
<location path="src/modules/appearance/appearanceinterfacev1.cpp" line_range="144-150" />
<code_context>
+    // once per-user resource tracking is available (e.g. track resources per
+    // client credentials / security context and push only to those).
+    //
+    // Current behavior: push to ALL bound clients unconditionally. If the new
+    // config hasn't finished async initialization, getters return DConfig
+    // default values, which is still better than stale values from the old
+    // config; later change signals will push actual values.
+    setupConfigConnections();
+    for (const auto &resource : d->server->resourceMap())
+        sendAll(resource->handle);
+}
+
</code_context>
<issue_to_address>
**🚨 issue (security):** The appearance globals never validate the requesting Wayland client's identity. Any local client can bind the supposedly privileged manager and invoke `set_*` requests to modify the current user's DConfig, while the read-only interface broadcasts the new user's values to every already-bound client after a user switch.

**Triggers:** When an untrusted local client binds the new globals, or when the active user changes while clients from the previous user remain connected.

**Suggested fix:** Restrict the manager global/bindings to authorized clients and track resources by user/security context before sending appearance values or accepting mutations.
</issue_to_address>

### Comment 3
<location path="src/modules/appearance/appearanceinterfacev1.cpp" line_range="164-167" />
<code_context>
+    if (!config)
+        return;
+
+    // Settings change signals. Initialization completion is not watched:
+    // bind_resource() and onConfigChanged() push values unconditionally, and
+    // uninitialized getters return DConfig defaults.
+    d->configConnections.append(
+        connect(config, &TreelandUserConfig::cursorThemeNameChanged, this, [this] {
+            const auto name = Helper::instance()->config()->cursorThemeName();
</code_context>
<issue_to_address>
**issue (bug_risk):** Clients that bind before `TreelandUserConfig::configInitializeSucceed` receive DConfig default values, but the interface does not connect to the initialization-success signal and therefore never re-pushes the actual settings when asynchronous initialization completes. The same stale-default state occurs after a user-config replacement that is still initializing.

**Triggers:** When a client binds during asynchronous DConfig initialization or immediately after a user switch.

**Suggested fix:** Connect each active config's `configInitializeSucceed` signal and call `sendAll` for all bound resources after initialization succeeds.
</issue_to_address>

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

Comment thread src/modules/personalization/CMakeLists.txt
Comment thread src/modules/appearance/appearanceinterfacev1.cpp
Comment thread src/modules/appearance/appearanceinterfacev1.cpp
@zccrs
zccrs merged commit 0b4b32c into linuxdeepin:master Sep 17, 2026
7 checks passed
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

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