Skip to content

feat: adapt dtkgui to Treeland 0.7.0 protocols - #416

Open
18202781743 wants to merge 1 commit into
masterfrom
agent/developer/6048769b90d8
Open

18202781743 wants to merge 1 commit into
masterfrom
agent/developer/6048769b90d8

Conversation

@18202781743

@18202781743 18202781743 commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

变更

适配 treeland-protocols 0.7.0,将旧 personalization 协议替换为
treeland-appearance-unstable-v1、treeland-decoration-unstable-v1 和
ext-background-effect-v1,并更新 Qt5/Qt6 协议生成及依赖要求。

  • 分离外观、装饰和背景效果的协议实现,沿用统一的窗口生命周期与属性调度。
  • 在首次 surface 配置完成后应用装饰,避免首屏设置在 SSD 协商前丢失。
  • 全窗模糊开关与局部区域独立保存,分别使用 BlurWindow、BlurRegion 标记;
    设置局部区域不修改全窗开关,关闭全窗后恢复保存的局部区域。
  • 保留字号除以 10、限制到 8.25~15.00 pt 的原有逻辑。
  • 外观强调色回调按 0.7.0 接口接收 RGB,分别检测装饰和模糊能力。

验证与待处理项

  • Qt5/Qt6 构建通过。
  • 客户端协议模拟回归通过,覆盖首屏及 surface 重建后的装饰恢复、局部区域
    连续更新与清除、全窗与局部区域独立保存及切换。
  • 远端系统库与构建库字号对比均为 10.5 pt;未改动远端 CMake 配置。
  • 真实 Treeland 模糊端到端验证待服务端实现后进行。
  • 审查指出的 surface 缩放坐标转换、缺少可选协议依赖时的构建行为尚待处理。

关联任务

Summary by Sourcery

Adapt dtkgui to Treeland 0.7.0 by replacing the personalization protocol with dedicated appearance, decoration, and background-effect integrations.

New Features:

  • Replace the legacy Treeland personalization integration with the 0.7.0 appearance, decoration, and background-effect protocols.
  • Support independent full-window and regional blur effects on Treeland surfaces.
  • Apply Treeland window decorations and effects reliably across initial surface configuration and surface recreation.

Bug Fixes:

  • Prevent initial decoration settings from being lost before the surface is exposed and decoration negotiation completes.
  • Preserve regional blur settings independently when toggling full-window blur.

Enhancements:

  • Update appearance handling for the 0.7.0 protocol, including RGB accent colors and existing font-size conversion and bounds.
  • Expose decoration and blur capabilities separately based on the protocols provided by the compositor.

Build:

  • Require TreelandProtocols 0.7.0 and WaylandProtocols 1.45, and generate Qt5/Qt6 client bindings for the new protocols.

Tests:

  • Update Treeland protocol configuration coverage for the new decoration protocol.

Chores:

  • Remove the obsolete personalization protocol client implementation and replace it with dedicated Treeland protocol extensions.

@18202781743
18202781743 marked this pull request as draft September 28, 2026 05:37
@github-actions

Copy link
Copy Markdown
Contributor
  • 检测到debian目录文件有变更: debian/control

@sourcery-ai

sourcery-ai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Adapts dtkgui’s Treeland backend from the legacy personalization protocol to Treeland 0.7.0 by generating and consuming separate appearance, decoration, and background-effect protocols, refactoring surface-lifecycle property application and independent blur state handling, and updating Qt5/Qt6 build dependencies.

Sequence diagram for surface property application

sequenceDiagram
    participant Window as QWindow
    participant Helper as DTreeLandPlatformWindowHelper
    participant Decoration as TreelandDecorationContext
    participant Effect as BackgroundEffectSurface

    Window->>Helper: SurfaceCreated
    Helper->>Helper: onSurfaceCreated()
    Window->>Helper: Expose
    Helper->>Helper: scheduleApply()
    Helper->>Decoration: set_titlebar_mode()
    Helper->>Decoration: set_corner_radius()
    Helper->>Effect: setBlurRegion()
    Helper->>Window: commit()
Loading

State diagram for independent Treeland blur modes

stateDiagram-v2
    [*] --> Disabled
    Disabled --> WindowBlur: setEnableBlurWindow(true)
    Disabled --> RegionBlur: setWindowBlurAreas() or setWindowBlurPaths()
    WindowBlur --> Disabled: setEnableBlurWindow(false)
    WindowBlur --> RegionBlur: setEnableBlurWindow(false)
    RegionBlur --> Disabled: setWindowBlurAreas() or setWindowBlurPaths() with empty region
    RegionBlur --> WindowBlur: setEnableBlurWindow(true)
Loading

File-Level Changes

Change Details Files
Replace the legacy Treeland personalization protocol with the 0.7.0 appearance, decoration, and background-effect protocol clients.
  • Generate Qt5 and Qt6 client bindings for the three new protocols.
  • Add appearance event handlers for fonts, icon theme, color scheme, accent RGB, opacity, and corner radius.
  • Add independent decoration and background-effect managers with capability detection.
src/plugins/platform/treeland/treelandappearanceclientextension.cpp
src/plugins/platform/treeland/treelandappearanceclientextension.h
src/plugins/platform/treeland/treelanddecorationclientextension.cpp
src/plugins/platform/treeland/treelanddecorationclientextension.h
src/plugins/platform/treeland/treelandbackgroundeffectclientextension.cpp
src/plugins/platform/treeland/treelandbackgroundeffectclientextension.h
src/plugins/platform/treeland/personalizationwaylandclientextension.cpp
src/plugins/platform/treeland/personalizationwaylandclientextension.h
src/plugins/plugins.cmake
src/plugins/platform/config.tests/treeland_test/CMakeLists.txt
src/plugins/platform/config.tests/treeland_test/main.cpp
Refactor window state dispatch to apply decoration and blur properties through a unified queued lifecycle.
  • Recreate protocol objects on surface creation and destruction, and defer decoration until the surface is exposed.
  • Track full-window blur and regional blur separately, preserving regional state when toggling the full-window mode.
  • Convert rectangular and painter-path blur inputs to Wayland regions and reapply state after capability, expose, resize, or surface changes.
  • Gate decoration and blur APIs independently based on the corresponding protocol capabilities.
src/plugins/platform/treeland/dtreelandplatformwindowinterface.cpp
src/plugins/platform/treeland/dtreelandplatformwindowinterface.h
src/kernel/dplatformhandle.cpp
Update Treeland platform theme and window-manager integration for the new protocol ownership and capability signals.
  • Route appearance callbacks directly into platform theme properties while retaining font-size scaling and clamping.
  • Replace personalization activation signals with decoration activation and blur-capability signals.
  • Expose blur and no-titlebar support independently.
src/plugins/platform/treeland/dtreelandplatforminterface.cpp
src/plugins/platform/treeland/dtreelandplatforminterface.h
src/plugins/platform/treeland/dtreelandwindowmanagerhelper.cpp
Raise and formalize the Treeland protocol build dependencies.
  • Require TreelandProtocols 0.7.0, ECM, and WaylandProtocols 1.45 when Treeland support is enabled.
  • Update Debian build dependencies accordingly.
src/plugins/plugins.cmake
src/plugins/platform/config.tests/treeland_test/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

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

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

## Individual Comments

### Comment 1
<location path="src/plugins/platform/treeland/dtreelandplatformwindowinterface.cpp" line_range="161-166" />
<code_context>
             return ret;
         }

-#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
-        QPointF delta = me->globalPosition() - self->m_pressPoint;
-#else
-        QPointF delta = me->globalPos() - self->m_pressPoint;
-#endif
-        if (delta.manhattanLength() < QGuiApplication::styleHints()->startDragDistance()) {
-            return ret;
-        }
</code_context>
<issue_to_address>
**issue (bug_risk):** The drag-distance guard was removed, so the first unaccepted left-button mouse move after a press starts a system window move regardless of how far the pointer moved. A click followed by a tiny pointer movement therefore initiates a window drag instead of preserving normal application mouse handling.

**Triggers:** When system move is enabled and a window receives a small mouse movement after a left-button press.

**Suggested fix:** Retain the `startDragDistance()` check using `m_pressPoint` before entering the system-move branch.
</issue_to_address>

### Comment 2
<location path="src/plugins/platform/treeland/dtreelandplatformwindowinterface.cpp" line_range="433-437" />
<code_context>
         }
     }
+
+    if (m_blurDirty) {
+        m_blurDirty = false;
+        if (m_blurEnabled && BackgroundEffectManager::instance()->isSupported()
+            && BackgroundEffectManager::instance()->hasBlurCapability()) {
+            if (!m_effectSurface) {
+                auto waylandWindow = dynamic_cast<QtWaylandClient::QWaylandWindow *>(window()->handle());
+                if (waylandWindow && waylandWindow->waylandSurface()) {
</code_context>
<issue_to_address>
**issue (bug_risk):** `applyPending()` clears `m_blurDirty` before checking whether the background-effect capability is available, while `blurCapabilityChanged()` only emits the window-manager-helper signal and never reschedules existing window helpers. If blur is enabled before the capability event arrives, the blur request is discarded and is never applied when the capability becomes available.

**Triggers:** When a window enables blur before the background-effect manager delivers its capabilities event.

**Suggested fix:** Keep the blur state dirty until it is applied, or connect the capability change to each helper and call `scheduleApply()` when blur becomes supported.
</issue_to_address>

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

Comment on lines -161 to -166
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QPointF delta = me->globalPosition() - self->m_pressPoint;
#else
QPointF delta = me->globalPos() - self->m_pressPoint;
#endif
if (delta.manhattanLength() < QGuiApplication::styleHints()->startDragDistance()) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): The drag-distance guard was removed, so the first unaccepted left-button mouse move after a press starts a system window move regardless of how far the pointer moved. A click followed by a tiny pointer movement therefore initiates a window drag instead of preserving normal application mouse handling.

Triggers: When system move is enabled and a window receives a small mouse movement after a left-button press.

Suggested fix: Retain the startDragDistance() check using m_pressPoint before entering the system-move branch.

Comment on lines +433 to +437
if (m_blurDirty) {
m_blurDirty = false;
if (m_blurEnabled && BackgroundEffectManager::instance()->isSupported()
&& BackgroundEffectManager::instance()->hasBlurCapability()) {
if (!m_effectSurface) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): applyPending() clears m_blurDirty before checking whether the background-effect capability is available, while blurCapabilityChanged() only emits the window-manager-helper signal and never reschedules existing window helpers. If blur is enabled before the capability event arrives, the blur request is discarded and is never applied when the capability becomes available.

Triggers: When a window enables blur before the background-effect manager delivers its capabilities event.

Suggested fix: Keep the blur state dirty until it is applied, or connect the capability change to each helper and call scheduleApply() when blur becomes supported.

@github-actions

Copy link
Copy Markdown
Contributor
  • 检测到debian目录文件有变更: debian/control

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor
  • 检测到debian目录文件有变更: debian/control

@18202781743
18202781743 force-pushed the agent/developer/6048769b90d8 branch from b59d9b3 to baa59ef Compare October 15, 2026 07:08
@github-actions

Copy link
Copy Markdown
Contributor
  • 检测到debian目录文件有变更: debian/control

@deepin-bot

deepin-bot Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 6.7.51
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #419

@18202781743
18202781743 force-pushed the agent/developer/6048769b90d8 branch from baa59ef to 82fe66f Compare October 15, 2026 12:58
@github-actions

Copy link
Copy Markdown
Contributor
  • 检测到debian目录文件有变更: debian/control

2 similar comments
@github-actions

Copy link
Copy Markdown
Contributor
  • 检测到debian目录文件有变更: debian/control

@github-actions

Copy link
Copy Markdown
Contributor
  • 检测到debian目录文件有变更: debian/control

@18202781743
18202781743 force-pushed the agent/developer/6048769b90d8 branch from 1ad8e43 to c6915b9 Compare October 16, 2026 06:50
@github-actions

Copy link
Copy Markdown
Contributor
  • 检测到debian目录文件有变更: debian/control

@github-actions

Copy link
Copy Markdown
Contributor
  • 检测到debian目录文件有变更: debian/control

@18202781743
18202781743 force-pushed the agent/developer/6048769b90d8 branch from f9a0f40 to a17749f Compare October 16, 2026 09:38
@github-actions

Copy link
Copy Markdown
Contributor
  • 检测到debian目录文件有变更: debian/control

1. Split the monolithic treeland-personalization-manager-v1 protocol
into three dedicated implementations: appearance (treeland-appearance-
unstable-v1), decoration (treeland-decoration-unstable-v1), and
background effect (ext-background-effect-v1)
2. Add new TreelandAppearance client extension to handle appearance
properties including font, font size (point size divided by 10 with
clamping to 8.25-15.00pt), icon theme, accent color, window opacity,
color scheme, titlebar height, and corner radius
3. Add new TreelandDecorationManager and TreelandDecorationContext to
handle window decoration properties like titlebar mode, corner radius,
border, and shadow
4. Add new BackgroundEffectManager and BackgroundEffectSurface to handle
blur window and blur region functionality with capability detection
5. Refactor DTreeLandPlatformWindowHelper to use separate feature flags
for BlurWindow and BlurRegion, storing them independently
6. Apply decoration only after the surface's first configure (check
isExposed) to avoid overriding xdg-decoration negotiation
7. Update DPlatformHandle to route blur area and blur path calls to the
new DTreeLandPlatformWindowInterface methods
8. Update treeland window manager helper to check decoration
and background effect managers separately for hasNoTitlebar and
hasBlurWindow
9. Update build dependencies to require treeland-protocols >= 0.7.0 and
wayland-protocols >= 1.45
10. Update CMake to scan the three new protocol XML files for both Qt6
and Qt5 builds
11. Remove obsolete personalizationwaylandclientextension files
12. Preserve uniform window lifecycle and property scheduling logic
while adding repositioning drag threshold handling

Log: Adapted to Treeland 0.7.0 split protocols for appearance,
decoration, and background effect; separated blur window toggle from
blur region with independent saving; applied decoration after first
surface configure

Influence:
1. Verify window decoration properties (titlebar, corner radius, border,
shadow) apply correctly on freshly created windows
2. Test blur window toggle and blur region independently - enabling one
should not affect the other
3. Verify blur area and blur path APIs route to background effect
protocol on Treeland
4. Test window resizing when blur window is enabled to ensure blur
region updates
5. Verify font size handling still divides by 10 and clamps to 8.25-
15.00pt range
6. Test window dragging with the updated manhattan length threshold
logic
7. Verify fallback behavior when Treeland protocols are unsupported
(returns false/empty values)
8. Check that decoration changes are not applied before the window is
exposed
9. Test blur capability changes triggering re-application of blur state
10. Verify build succeeds with treeland-protocols 0.7.0 and wayland-
protocols 1.45

feat: 适配 Treeland 0.7.0 协议拆分

1. 将单一的 treeland-personalization-manager-v1 协议拆分为三个独立实
现:appearance(treeland-appearance-unstable-v1)、decoration(treeland-
decoration-unstable-v1)和 background effect(ext-background-effect-v1)
2. 新增 TreelandAppearance 客户端扩展,处理外观属性,包括字体、字号
(pointSize 除以 10 并限制在 8.25-15.00pt 范围内)、图标主题、强调色、窗
口不透明度、配色方案、标题栏高度和圆角半径
3. 新增 TreelandDecorationManager 和 TreelandDecorationContext,处理窗口
装饰属性,如标题栏模式、圆角半径、边框和阴影
4. 新增 BackgroundEffectManager 和 BackgroundEffectSurface,处理全窗模糊
和局部区域模糊功能,并支持能力检测
5. 重构 DTreeLandPlatformWindowHelper,使用独立的特性标记 BlurWindow 和
BlurRegion,并分别保存
6. 在 surface 首次 configure 完成后(检查 isExposed)才应用装饰,避免覆
盖 xdg-decoration 协商结果
7. 更新 DPlatformHandle,将模糊区域和模糊路径的调用路由到新的
DTreeLandPlatformWindowInterface 方法
8. 更新 treeland 窗口管理器辅助类,分别检查 decoration 和 background
effect 管理器以确定 hasNoTitlebar 和 hasBlurWindow
9. 更新构建依赖,要求 treeland-protocols >= 0.7.0 和 wayland-protocols
>= 1.45
10. 更新 CMake,为 Qt6 和 Qt5 构建扫描三个新的协议 XML 文件
11. 移除废弃的 personalizationwaylandclientextension 文件
12. 保留统一窗口生命周期和属性调度逻辑,同时增加拖拽重定位阈值处理

Log: 适配 Treeland 0.7.0 拆分协议,涵盖 appearance、decoration 和
background effect;全窗模糊开关与局部区域模糊独立保存;首次 surface 配置
完成后应用装饰

Influence:
1. 验证窗口装饰属性(标题栏、圆角、边框、阴影)在新建窗口上正确应用
2. 单独测试全窗模糊开关和局部区域模糊 - 启用其中一个不应影响另一个
3. 验证模糊区域和模糊路径 API 在 Treeland 上正确路由到 background effect
协议
4. 启用全窗模糊时测试窗口缩放,确保模糊区域正确更新
5. 验证字号处理逻辑仍除以 10 并限制在 8.25-15.00pt 范围内
6. 使用更新后的曼哈顿距离阈值逻辑测试窗口拖拽功能
7. 验证 Treeland 协议不支持时的回退行为(返回 false/空值)
8. 检查窗口未 exposed 前装饰变更不会被应用
9. 测试模糊能力变化触发模糊状态重新应用
10. 验证使用 treeland-protocols 0.7.0 和 wayland-protocols 1.45 构建成功

PMS: TASK-396717
@18202781743
18202781743 force-pushed the agent/developer/6048769b90d8 branch from a17749f to 02ac591 Compare October 16, 2026 10:17
@github-actions

Copy link
Copy Markdown
Contributor
  • 检测到debian目录文件有变更: debian/control

@18202781743 18202781743 changed the title fix: adapt dtkgui to Treeland protocol 0.6.0 API changes feat: adapt dtkgui to Treeland 0.7.0 protocols Oct 16, 2026
@18202781743
18202781743 requested review from BLumia and mhduiy October 16, 2026 10:22
@18202781743
18202781743 marked this pull request as ready for review October 16, 2026 10:22

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

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

## Individual Comments

### Comment 1
<location path="src/plugins/plugins.cmake" line_range="58-63" />
<code_context>
 pkg_check_modules(WAYLAND_CLIENT REQUIRED wayland-client)

-find_package(TreelandProtocols)
+find_package(TreelandProtocols 0.7.0 REQUIRED)
 set(TreelandProtocols_FOUND ${TreelandProtocols_FOUND})
+find_package(ECM REQUIRED NO_MODULE)
+set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${ECM_MODULE_PATH}")
+find_package(WaylandProtocols 1.45 REQUIRED)

 add_executable(${PROJECT_NAME} main.cpp)
</code_context>
<issue_to_address>
**Optional Treeland dependencies block configuration**

When the build environment lacks treeland-protocols 0.7.0 or wayland-protocols 1.45, cMake now requires Treeland and Wayland protocol packages while configuring Treeland support. A build environment without those optional packages fails configuration instead of simply omitting the Treeland backend, preventing builds for other supported platforms.

Treat these packages as optional during feature detection and disable Treeland support when they are unavailable.

Also at `src/plugins/platform/config.tests/treeland_test/CMakeLists.txt:22-26`.
</issue_to_address>

### Comment 2
<location path="src/kernel/dplatformhandle.cpp" line_range="613-615" />
<code_context>
+#endif
+#ifndef DTK_DISABLE_TREELAND
+    if (auto impl = dynamic_cast<DTreeLandPlatformWindowInterface *>(platformWindowImpl(&handle))) {
+        impl->setWindowBlurAreas(area);
+        return true;
+    }
 #endif
     handle.setEnableBlurWindow(true);
</code_context>
<issue_to_address>
**Platform support documentation is outdated**

The new Treeland routing makes some `DPlatformHandle` operations effective outside the DXCB/X11 platform, contradicting the class description that says its functionality is implemented by DXCB and the class has no effect on other platforms. Consumers relying on that description are misled about Treeland support.

Update the class description to identify the Treeland-supported operations and distinguish them from DXCB-only functionality.
</issue_to_address>

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

Comment thread src/plugins/plugins.cmake
Comment on lines +58 to +63
find_package(TreelandProtocols 0.7.0 REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS WaylandClient)
set(TreelandProtocols_FOUND ${TreelandProtocols_FOUND})
find_package(ECM REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${ECM_MODULE_PATH}")
find_package(WaylandProtocols 1.45 REQUIRED)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 High · Optional Treeland dependencies block configuration

When the build environment lacks treeland-protocols 0.7.0 or wayland-protocols 1.45, cMake now requires Treeland and Wayland protocol packages while configuring Treeland support. A build environment without those optional packages fails configuration instead of simply omitting the Treeland backend, preventing builds for other supported platforms.

Treat these packages as optional during feature detection and disable Treeland support when they are unavailable.

Also at src/plugins/platform/config.tests/treeland_test/CMakeLists.txt:22-26.

Prompt for AI agents
In `src/plugins/plugins.cmake` at lines 58-63:

**Optional Treeland dependencies block configuration**

When the build environment lacks treeland-protocols 0.7.0 or wayland-protocols 1.45, cMake now requires Treeland and Wayland protocol packages while configuring Treeland support. A build environment without those optional packages fails configuration instead of simply omitting the Treeland backend, preventing builds for other supported platforms.

Treat these packages as optional during feature detection and disable Treeland support when they are unavailable.

Also at `src/plugins/platform/config.tests/treeland_test/CMakeLists.txt:22-26`.

Comment on lines +613 to +615
impl->setWindowBlurAreas(area);
return true;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚪ Low · Platform support documentation is outdated

The new Treeland routing makes some DPlatformHandle operations effective outside the DXCB/X11 platform, contradicting the class description that says its functionality is implemented by DXCB and the class has no effect on other platforms. Consumers relying on that description are misled about Treeland support.

Update the class description to identify the Treeland-supported operations and distinguish them from DXCB-only functionality.

Prompt for AI agents
In `src/kernel/dplatformhandle.cpp` at lines 613-615:

**Platform support documentation is outdated**

The new Treeland routing makes some `DPlatformHandle` operations effective outside the DXCB/X11 platform, contradicting the class description that says its functionality is implemented by DXCB and the class has no effect on other platforms. Consumers relying on that description are misled about Treeland support.

Update the class description to identify the Treeland-supported operations and distinguish them from DXCB-only functionality.

@deepin-ci-robot

Copy link
Copy Markdown
Contributor

deepin pr auto review

AI 代码审查报告

项目: linuxdeepin/dtkgui
PR: #416
分支: agent/developer/6048769b90d8 → master
提交: feat: adapt dtkgui to Treeland 0.7.0 protocols
审查时间: 2026-10-16 18:21


总体评价

总分: 98/100
风险等级: 无风险 (None)
评价: 代码审查通过

本次 PR 将 dtkgui 从旧的 treeland-personalization-manager-v1 协议适配到 Treeland 0.7.0 的新协议体系,将原单一协议拆分为三个独立协议(treeland-appearance-unstable-v1、treeland-decoration-unstable-v1、ext-background-effect-v1),职责分离更清晰。代码结构合理,资源管理规范,无安全漏洞。存在少量代码重复问题,但不影响整体质量。


漏洞统计

指标 数量
当前漏洞总数 0
新增漏洞 0
修复漏洞 0
持平 0

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个


四维度评分

维度 评分 状态 评价词
语法逻辑 (25分) 25 ✓ 语法正确,逻辑清晰
代码质量 (25分) 23 ✓ 代码结构清晰,注释完整
代码性能 (20分) 20 ✓ 性能良好,资源使用合理
代码安全 (30分) 30 ✓ 存在0个安全漏洞

维度1:语法逻辑 (25/25 ✓)

语法正确,逻辑清晰

审查内容:

  1. dplatformhandle.cpp 中新增的 #ifndef DTK_DISABLE_TREELAND 块在 setWindowBlurAreaByWM 和 setWindowBlurAreaByWM (paths 版本) 中位置正确,在 DXCB 平台检查之后、默认处理之前返回,逻辑合理。

  2. MoveWindowHelper::windowEvent 中移除了重复的距离判断代码,将判断提前到鼠标事件处理开始处。新增的 m_pressPoint.isNull() 检查防止了在未按下时计算距离的问题,这是一个合理的 bug 修复。

  3. applyPending() 中 blur 区域处理逻辑完整:空区域时清理 m_backgroundEffectSurface 并清除 dirty 标记,非空时通过 backgroundEffectSurface() 获取或创建 surface 并设置 blur region,最后在有变化时提交 wayland surface。

  4. decorationContext() 中新增 waylandWindow->isExposed() 检查,注释说明"Qt exposes the window after acknowledging the initial xdg_surface configure, including the xdg-decoration negotiation",避免了在窗口未暴露时创建装饰上下文。

  5. m_blurOpacity 类型从 uint32_t 改为 qreal,与 wl_fixed_to_double() 返回值类型匹配,消除了类型不一致问题。

  6. updateFeature 模板重构为两个重载:一个同时更新成员变量和标记,一个仅标记 dirty。调用链清晰,无递归或循环风险。

  7. 构造函数中 new TreelandAppearance(this) 在 TreelandAppearance 构造函数内调用 setParent(interface) 确保对象树管理正确,无需手动 delete。

无语法逻辑问题。


维度2:代码质量 (23/25 ✓)

代码结构清晰,注释完整

审查内容:

  1. 注释完整性: 新增文件均包含 SPDX 版权声明和 LGPL 许可证声明。关键设计决策有行内注释说明,如 "Qt exposes the window after acknowledging the initial xdg_surface configure"、"Treeland stores the point size multiplied by 10"、"Unconfigured surfaces receive the pending blur state with their first frame"。Q_UNUSED 标记的方法表明这些设置在 Treeland 0.7.0 中不再通过 appearance 接口设置,符合适配目的。

  2. 代码重复 (-2分): treelanddecorationclientextension.cpp 和 treelandbackgroundeffectclientextension.cpp 中的 Manager 类实现结构高度相似——构造函数(获取 Wayland integration、display、注册 listener、检查 registry global)、addListener()、removeListener()、handleListenerGlobal()、instance() 方法几乎完全相同,仅接口名称不同。这是 Wayland 客户端扩展的常见模式,但可考虑通过模板或基类减少重复。

  3. 结构合理性: 将单一 PersonalizationManager 拆分为 TreelandDecorationManager、BackgroundEffectManager 和 TreelandAppearance 三个独立类,职责分离更清晰:装饰管理负责标题栏/圆角/边框/阴影,背景效果管理负责 blur 区域,外观管理负责字体/主题/颜色监听。

  4. 调试信息清理: qWarning() 输出用于 Wayland 集成层面的运行时诊断(如 "waylandIntegration is nullptr!!!"、"waylandDisplay is nullptr!!!"),属于合理的错误处理,非残留调试代码。


维度3:代码性能 (20/20 ✓)

性能良好,资源使用合理

审查内容:

  1. scheduleApply() 使用 m_applyScheduled 标志防止重复调度,applyPending() 在执行前清除标志,避免不必要的重复调用。

  2. QMetaObject::invokeMethod 使用 Qt::QueuedConnection(原代码未指定连接类型),确保在事件循环中异步执行 apply,避免在事件处理中同步执行可能导致的重入问题。

  3. backgroundEffectSurface() 和 decorationContext() 均使用延迟初始化(lazy initialization),仅在首次需要时创建对象,避免不必要的资源分配。

  4. setWindowBlurAreas 中将 WMBlurArea 列表转换为 QRegion 的遍历操作复杂度为 O(n),对于典型的窗口 blur 区域数量(通常 < 100)性能良好。

  5. BackgroundEffectSurface::setBlurRegion 中创建 Wayland region 后立即调用 wl_region_destroy 释放,无资源泄漏。

  6. 新增的 Expose 和 Resize 事件处理通过 scheduleApply() 触发,利用去重机制避免频繁调用。

无性能问题。


维度4:代码安全 (30/30 ✓)

存在0个安全漏洞

审查内容:

  1. 输入校验: decorationContext() 和 backgroundEffectSurface() 中对 dynamic_cast 结果、waylandWindow、waylandSurface、surface 均有 nullptr 检查,防止空指针解引用。

  2. 资源管理: 析构函数中正确清理 m_decorationContext 和 m_backgroundEffectSurface,onSurfaceDestroyed() 也清理这两个指针。Wayland region 在 setBlurRegion 中使用后立即销毁。

  3. 类型安全: static_cast<int>(r)、static_cast<int>(g)、static_cast<int>(b) 用于 uint32_t 到 int 的颜色分量转换,在合理范围内(0-255)不会溢出。

  4. 无安全漏洞: 无命令注入、SQL 注入、路径遍历、硬编码密钥、缓冲区溢出等安全风险。无用户输入直接拼接到命令或查询的场景。

安全合规。


改进建议

  1. 减少 Manager 类代码重复: 考虑为 Wayland 客户端扩展 Manager 类创建一个模板基类,封装通用的初始化、listener 注册和单例逻辑,减少 TreelandDecorationManager 和 BackgroundEffectManager 之间的代码重复。
// 示例:模板基类减少重复
template<typename Derived, typename Interface>
class WaylandManagerBase : public QWaylandClientExtensionTemplate<Derived>,
                           public QtWayland::Interface
{
public:
    static Derived *instance() {
        static Derived inst;
        return &inst;
    }
    [[nodiscard]] inline bool isSupported() const { return m_isSupported; }

protected:
    WaylandManagerBase() : m_isSupported(false) {
        auto *waylandIntegration = static_cast<QtWaylandClient::QWaylandIntegration *>(
            QGuiApplicationPrivate::platformIntegration());
        if (!waylandIntegration) {
            qWarning() << "waylandIntegration is nullptr!!!";
            return;
        }
        m_waylandDisplay = waylandIntegration->display();
        if (!m_waylandDisplay) {
            qWarning() << "waylandDisplay is nullptr!!!";
            return;
        }
        m_waylandDisplay->addRegistryListener(&handleListenerGlobal, this);
        m_isSupported = m_waylandDisplay->hasRegistryGlobal(
            QString::fromUtf8(Interface::interface.name));
    }

private:
    static void handleListenerGlobal(void *data, wl_registry *registry,
                                     uint32_t id, const QString &interface,
                                     uint32_t version) {
        if (interface == Interface::interface.name) {
            auto *self = static_cast<Derived *>(data);
            if (self) self->init(registry, id, version);
        }
    }

    QtWaylandClient::QWaylandDisplay *m_waylandDisplay = nullptr;
    bool m_isSupported;
};

审查结论

本次 PR 将 dtkgui 适配到 Treeland 0.7.0 协议体系,将原单一 PersonalizationManager 拆分为三个独立的协议管理器,职责分离更清晰。代码逻辑正确,资源管理规范,无安全漏洞。MoveWindowHelper 中的 bug 修复(移除重复距离判断、新增 pressPoint 空值检查)提升了代码健壮性。建议通过模板基类减少 Manager 类的代码重复,但不影响本次审查通过。

@deepin-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, BLumia

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

This branch has not been deployed

No deployments
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