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 personalization support with the new appearance, decoration, and background-effect protocols.

New Features:

  • Replace the legacy Treeland personalization integration with the 0.7.0 appearance, decoration, and background-effect protocols.
  • Add independent support for full-window and regional blur effects, including persistence across surface recreation and capability changes.

Bug Fixes:

  • Apply decoration settings after the initial surface configuration so first-screen window styling is retained.

Enhancements:

  • Update appearance handling for Treeland 0.7.0 notifications, including RGB accent colors and bounded fractional font sizes.
  • Gate window decoration and blur functionality on the corresponding compositor capabilities and preserve existing window lifecycle updates.

Build:

  • Require TreelandProtocols 0.7.0 and WaylandProtocols 1.45, and update Qt5 and Qt6 protocol generation for the new interfaces.

Tests:

  • Update the Treeland protocol configuration test to validate the new decoration protocol.

Chores:

  • Remove the obsolete personalization Wayland client extension and introduce dedicated appearance, decoration, and background-effect client 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

Data structures

Introduce separate manager, context, and surface client-extension types for Treeland appearance, decoration, and background-effect protocols.

  • src/plugins/platform/treeland/dtreelandplatforminterface.h L22-25 (+3 small edits)
  • src/plugins/platform/treeland/dtreelandplatformwindowinterface.h L11-17, L27-31, L48-51 (+8 small edits)
  • src/plugins/platform/treeland/treelandappearanceclientextension.h L1-47
  • src/plugins/platform/treeland/treelandbackgroundeffectclientextension.h L1-61
  • src/plugins/platform/treeland/treelanddecorationclientextension.h L1-50

API

Extend platform-window blur APIs to route rectangular areas and painter paths to the Treeland implementation.

  • src/kernel/dplatformhandle.cpp L610-615, L672-677

Uses of the API

Report titlebar and blur availability from their respective Treeland protocol managers.

  • src/plugins/platform/treeland/dtreelandwindowmanagerhelper.cpp L14-17 (+4 small edits)

Implementation

Implement appearance event handling and update platform-interface state from the new protocol callbacks.

  • src/plugins/platform/treeland/dtreelandplatforminterface.cpp L29-34 (+9 small edits)
  • src/plugins/platform/treeland/treelandappearanceclientextension.cpp L1-114

Implement decoration and background-effect protocol managers and their surface/context wrappers.

  • src/plugins/platform/treeland/treelandbackgroundeffectclientextension.cpp L1-94
  • src/plugins/platform/treeland/treelanddecorationclientextension.cpp L1-77

Refactor Treeland window lifecycle, decoration scheduling, blur-region state, capability updates, and dragging behavior for the split protocols.

  • src/plugins/platform/treeland/dtreelandplatformwindowinterface.cpp L319-345, L393-422, L470-495 (+31 small edits)

Remove the obsolete personalization protocol client implementation replaced by the new protocol extensions.

  • src/plugins/platform/treeland/personalizationwaylandclientextension.cpp (deleted)
  • src/plugins/platform/treeland/personalizationwaylandclientextension.h (deleted)

Configuration

Require TreelandProtocols 0.7.0 and WaylandProtocols 1.45 and generate the new protocol bindings for Qt5 and Qt6.

  • debian/control L12-13
  • src/plugins/platform/config.tests/treeland_test/CMakeLists.txt L22-26, L45-57 (+2 small edits)
  • src/plugins/plugins.cmake L58-63, L70-73, L79-88 (+1 small edits)

Tests

Update the Treeland protocol configuration test to exercise the new decoration context protocol.

  • src/plugins/platform/config.tests/treeland_test/main.cpp L1, L12, L20-28

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 ✨

@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

@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

[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

@deepin-bot

deepin-bot Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 6.7.52
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #420

@deepin-bot

deepin-bot Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 6.7.53
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #423

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 02ac591 to e572dbf Compare November 13, 2026 07:03
@github-actions

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

@deepin-ci-robot

Copy link
Copy Markdown
Contributor

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 86 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次 PR 将 dtkgui 从旧版 treeland-personalization-manager-v1 协议迁移至 Treeland 0.7.0 的三套新协议(treeland-appearance-unstable-v1、treeland-decoration-unstable-v1、ext-background-effect-v1),重构结构清晰、职责分离合理。四维度均通过,存在0个安全漏洞。主要问题集中在:dirty flags 未清理导致潜在重复 applyPending 调用、多个新 manager 类中 removeListener 为死代码、m_titleHeight/m_blurOpacity 为死数据、setBlurRegion 缺少 null 防御、CMake REQUIRED 关键字改变降级行为等。建议修复后合并。

🔍 详细分析

1. 语法逻辑 ✅

评价: 语法正确,逻辑清晰 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ['在 applyPending() 的 blur 非空分支中,当 backgroundEffectSurface() 返回 null 时也清除 dirty flags,或添加计数器限制重试次数避免无限重试', '在 handleListenerGlobal() 中匹配到接口时同步设置 m_isSupported = true', '在 treeland_appearance_v1_accent_color 中使用 qBound(0u, r, 255u) 对 RGB 值做范围限制']


2. 代码质量 ✅

评价: 代码结构清晰,注释完整 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ["为空实现的 setter 方法添加注释说明原因(如'设置由 compositor 通过 appearance 协议事件下发,客户端不需要主动设置')", '移除从未调用的 removeListener() 方法,或添加析构函数进行清理', '为 m_titleHeight 和 m_blurOpacity 添加 getter 或信号,或在不需要时移除成员和回调', '将 m_decorationContext 和 m_backgroundEffectSurface 声明为 mutable,移除 const_cast', '移除未使用的前向声明,为 bool 成员添加 = false 默认初始化器', "将 '!!!' 日志改为更专业的描述性消息"]


3. 代码性能 ✅

评价: 性能良好,资源使用合理 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ['在 backgroundEffectSurface() 返回 null 时也清除 dirty flags,或添加重试计数器/退避机制避免频繁重试']


4. 代码安全 🔒

评价: 存在0个安全漏洞 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: ['在 setBlurRegion() 中添加 display 和 wlRegion 的 null 检查', '在 removeListener() 中添加 m_waylandDisplay null 检查(或移除死代码)', '在 static_cast 前通过 QGuiApplication::platformName() 检查平台,或使用 dynamic_cast']


💡 改进建议代码示例

// 修复1: applyPending() 中清除 dirty flags 避免重复调用
void DTreeLandPlatformWindowHelper::applyPending()
{
    m_applyScheduled = false;
    // ... decoration context handling ...

    const auto blurFeatures = Features(BlurWindow) | BlurRegion;
    if (m_dirty & blurFeatures) {
        const QRegion region = m_blurWindowEnabled
            ? QRegion(QRect(QPoint(0, 0), window()->size())) : m_blurRegion;
        auto waylandWindow = dynamic_cast<QtWaylandClient::QWaylandWindow *>(window()->handle());
        bool changed = false;
        if (region.isEmpty()) {
            changed = m_backgroundEffectSurface != nullptr;
            delete m_backgroundEffectSurface;
            m_backgroundEffectSurface = nullptr;
            m_dirty &= ~blurFeatures;
        } else {
            auto manager = BackgroundEffectManager::instance();
            if (manager->hasBlurCapability() && waylandWindow) {
                if (auto effect = backgroundEffectSurface()) {
                    effect->setBlurRegion(region, waylandWindow->display());
                    m_dirty &= ~blurFeatures;
                    changed = true;
                }
            }
            // 即使 surface 未就绪也清除 flags,避免每次 Expose 重复触发
            // surface 就绪后通过 blurCapabilityChanged 信号重新标记 dirty
            if (m_dirty & blurFeatures) {
                m_dirty &= ~blurFeatures;
            }
        }
        if (changed && waylandWindow && waylandWindow->isExposed())
            waylandWindow->commit();
    }
}

// 修复2: setBlurRegion 添加 null 防御
void BackgroundEffectSurface::setBlurRegion(const QRegion &region,
                                             QtWaylandClient::QWaylandDisplay *display)
{
    if (!display) {
        qWarning() << "BackgroundEffectSurface::setBlurRegion: display is null";
        return;
    }
    auto wlRegion = display->createRegion(region);
    if (!wlRegion) {
        qWarning() << "BackgroundEffectSurface::setBlurRegion: failed to create wl_region";
        return;
    }
    set_blur_region(wlRegion);
    wl_region_destroy(wlRegion);
}

// 修复3: accent_color RGB 值范围限制
void TreelandAppearance::treeland_appearance_v1_accent_color(uint32_t r, uint32_t g, uint32_t b)
{
    if (m_interface) {
        m_interface->m_activeColor = QColor(
            static_cast<int>(qBound(0u, r, 255u)),
            static_cast<int>(qBound(0u, g, 255u)),
            static_cast<int>(qBound(0u, b, 255u)));
        emit m_interface->m_platformTheme->activeColorChanged(m_interface->m_activeColor);
    }
}

本报告由 AI 代码审查工具自动生成

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