Repository navigation
Conversation
|
Skipping CI for Draft Pull Request. |
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's GuideUpdates both Treeland output consumers from v1 to the v2 output manager, introducing asynchronous UUID-based QScreen mapping for primary-output selection and brightness control, with lifecycle/error handling for null, failed, and stale protocol objects. Build configuration now requires TreelandProtocols 0.9 and generates the v2 output-manager plus output-UUID clients. Sequence diagram for UUID-based primary output selectionsequenceDiagram
participant Compositor
participant Watcher as TreelandOutputWatcher
participant UUIDManager as TreelandOutputUuidManager
participant Screen as QScreen
participant Qt as QtScreenSystem
Compositor->>Watcher: treeland_output_manager_v2_primary_output(uuid)
Watcher->>Watcher: applyPrimary(uuid)
alt UUID mapping available
Watcher->>Qt: handlePrimaryScreenChanged(screen.handle())
else UUID not mapped yet
Watcher->>Watcher: requestUuid(screen)
Watcher->>UUIDManager: get_uuid(wl_output)
UUIDManager-->>Watcher: uuidReceived(uuid)
Watcher->>Watcher: applyPrimary(uuid)
end
alt compositor reports failure
Compositor->>Watcher: treeland_output_manager_v2_primary_output_failed(reason)
Watcher->>Watcher: clear pending UUID
end
Sequence diagram for UUID-based brightness controlsequenceDiagram
participant Brightness as TreelandBrightness
participant UUIDManager as TreelandOutputUuidManager
participant UUIDRequest as TreelandOutputUuid
participant OutputManager as OutputManagerV2
participant Control as TreelandPictureControl
participant Compositor
Brightness->>UUIDManager: get_uuid(wl_output)
UUIDManager-->>UUIDRequest: uuidReceived(uuid)
UUIDRequest-->>Brightness: uuidReceived(uuid)
Brightness->>OutputManager: get_picture_control(uuid)
OutputManager-->>Control: picture control object
Compositor-->>Control: treeland_output_picture_control_v2_brightness(brightness)
Control-->>Brightness: brightnessChanged(brightness)
Compositor-->>Control: treeland_output_picture_control_v2_result(result)
alt invalid output result
Brightness->>Brightness: delete m_control
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
TAG Bot New tag: 2.0.54 |
|
TAG Bot New tag: 2.0.55 |
|
TAG Bot New tag: 2.0.56 |
|
TAG Bot New tag: 2.0.57 |
|
TAG Bot New tag: 2.0.58 |
|
TAG Bot New tag: 2.0.59 |
|
TAG Bot New tag: 2.0.60 |
|
TAG Bot New tag: 2.0.61 |
4009139 to
6c5c101
Compare
|
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
5fdbc6e to
86f4a5f
Compare
1. 更新 CMakeLists 的 find_package 要求 TreelandProtocols 0.9 2. 迁移 treelandoutputwatcher 至 treeland_output_manager_v2 3. 迁移 treelandbrightness 从 color_control_v1 到 picture_control_v2 4. primary_output 事件回调从 wl_output* 改为 const QString &uuid 5. get_picture_control 请求从 wl_output* 改为 const QString &uuid 6. 新增 TreelandOutputUuidManager 和 TreelandOutputUuid 建立 wl_output→uuid 映射 7. 主屏匹配方式从指针比较改为 UUID 映射表查找 8. 补充 result 事件处理,含 commit_result 枚举(invalid_output=3) 9. 补充 primary_output_failed 事件处理 10. 缓存 pending primary uuid 处理时序问题 11. 处理屏幕移除并修复 TreelandOutputUuid 生命周期 12. 修复重复的 SPDX-FileCopyrightText 行 13. 更新 debian/control 构建依赖为 treeland-protocols (>= 0.9.0) 14. 提取 TreelandOutputUuidManager/TreelandOutputUuid 到共享头文件 shell/treelandoutputuuid.h,消除 shell 与 osd/brightness 模块间的重复定义 Log: 迁移 treeland output 协议消费者从 v1 到 v2 并适配 UUID 标识,提取共享 UUID 类消除重复代码 Influence: 多屏环境下主屏切换、OSD 亮度显示、屏幕热插拔 Ref: DDE-541
86f4a5f to
6422835
Compare
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="panels/notification/osd/brightness/treelandbrightness.cpp" line_range="90-91" />
<code_context>
+ m_currentUuid.clear();
- if (!output) {
+ if (!screen) {
return;
}
</code_context>
<issue_to_address>
**Brightness stays bound to old output**
When the primary screen changes or disappears while a UUID request is outstanding and the new screen has no usable Wayland output, `refresh()` and `requestPrimaryUuid()` return without cancelling the old request, so its callback passes the sender check and installs a picture control for the previous output; the OSD then reports stale brightness.
Cancel or invalidate the outstanding UUID request before returning when the primary screen has no usable Wayland output.
Also at `panels/notification/osd/brightness/treelandbrightness.cpp:102-118`, `panels/notification/osd/brightness/treelandbrightness.cpp:120-122`.
</issue_to_address>
### Comment 2
<location path="panels/notification/osd/brightness/treelandbrightness.cpp" line_range="124-125" />
<code_context>
+ if (sender() != m_uuidRequest)
+ return;
+
+ if (uuid.isEmpty())
+ return;
+
+ m_currentUuid = uuid;
</code_context>
<issue_to_address>
**Brightness monitoring stops after lookup failures**
When the UUID is empty, `get_picture_control()` returns null, or the picture control reports `commit_result_invalid_output`, `TreelandBrightness` returns or clears its control without retrying UUID/control resolution or notifying brightness consumers, so `brightness()` returns zero or the OSD retains stale brightness until an unrelated refresh.
Retry UUID/control resolution and notify brightness consumers on each failed resolution path.
Also at `panels/notification/osd/brightness/treelandbrightness.cpp:132-133`, `panels/notification/osd/brightness/treelandbrightness.cpp:139-144`.
</issue_to_address>| if (!screen) { | ||
| return; |
There was a problem hiding this comment.
🟡 Medium · Brightness stays bound to old output
When the primary screen changes or disappears while a UUID request is outstanding and the new screen has no usable Wayland output, refresh() and requestPrimaryUuid() return without cancelling the old request, so its callback passes the sender check and installs a picture control for the previous output; the OSD then reports stale brightness.
Cancel or invalidate the outstanding UUID request before returning when the primary screen has no usable Wayland output.
Also at panels/notification/osd/brightness/treelandbrightness.cpp:102-118, panels/notification/osd/brightness/treelandbrightness.cpp:120-122.
Prompt for AI agents
In `panels/notification/osd/brightness/treelandbrightness.cpp` at lines 90-91:
**Brightness stays bound to old output**
When the primary screen changes or disappears while a UUID request is outstanding and the new screen has no usable Wayland output, `refresh()` and `requestPrimaryUuid()` return without cancelling the old request, so its callback passes the sender check and installs a picture control for the previous output; the OSD then reports stale brightness.
Cancel or invalidate the outstanding UUID request before returning when the primary screen has no usable Wayland output.
Also at `panels/notification/osd/brightness/treelandbrightness.cpp:102-118`, `panels/notification/osd/brightness/treelandbrightness.cpp:120-122`.| if (uuid.isEmpty()) | ||
| return; |
There was a problem hiding this comment.
🟡 Medium · Brightness monitoring stops after lookup failures
When the UUID is empty, get_picture_control() returns null, or the picture control reports commit_result_invalid_output, TreelandBrightness returns or clears its control without retrying UUID/control resolution or notifying brightness consumers, so brightness() returns zero or the OSD retains stale brightness until an unrelated refresh.
Retry UUID/control resolution and notify brightness consumers on each failed resolution path.
Also at panels/notification/osd/brightness/treelandbrightness.cpp:132-133, panels/notification/osd/brightness/treelandbrightness.cpp:139-144.
Prompt for AI agents
In `panels/notification/osd/brightness/treelandbrightness.cpp` at lines 124-125:
**Brightness monitoring stops after lookup failures**
When the UUID is empty, `get_picture_control()` returns null, or the picture control reports `commit_result_invalid_output`, `TreelandBrightness` returns or clears its control without retrying UUID/control resolution or notifying brightness consumers, so `brightness()` returns zero or the OSD retains stale brightness until an unrelated refresh.
Retry UUID/control resolution and notify brightness consumers on each failed resolution path.
Also at `panels/notification/osd/brightness/treelandbrightness.cpp:132-133`, `panels/notification/osd/brightness/treelandbrightness.cpp:139-144`.
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: ['requestPrimaryUuid() 中 lambda 内部变量 raw(第187行)与外部作用域 raw(第169行)同名构成变量遮蔽,建议将内部变量重命名为 picRaw 以提高可读性。'] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: ['为 TreelandOutputUuidManager 和 TreelandOutputUuid 添加简短的类级别注释说明其用途', '将 requestPrimaryUuid() lambda 内的 raw 重命名为 picRaw 或 controlRaw 以消除变量遮蔽', '统一对象删除方式,建议 onScreenRemoved() 中也使用 deleteLater()'] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: [] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: [] 💡 改进建议代码示例// 建议:消除变量遮蔽并统一删除方式
void TreelandBrightness::requestPrimaryUuid()
{
// ... 前置检查不变 ...
auto *raw = m_uuidManager->get_uuid(output);
if (!raw)
return;
m_uuidRequest = new ::TreelandOutputUuid(raw, this);
connect(m_uuidRequest, &::TreelandOutputUuid::uuidReceived, this, [this](const QString &uuid) {
if (sender() != m_uuidRequest)
return;
if (uuid.isEmpty())
return;
m_currentUuid = uuid;
delete m_uuidRequest;
m_uuidRequest = nullptr;
// 重命名 raw -> picRaw,消除与外部 raw 的变量遮蔽
auto *picRaw = get_picture_control(uuid);
if (!picRaw)
return;
m_control = new TreelandPictureControl(picRaw, this);
connect(m_control, &TreelandPictureControl::brightnessChanged,
this, &TreelandBrightness::brightnessChanged);
connect(m_control, &TreelandPictureControl::resultReceived, this, [this](uint32_t result) {
if (result == TreelandPictureControl::commit_result_invalid_output) {
delete m_control;
m_control = nullptr;
m_currentUuid.clear();
}
});
});
}
// 建议:onScreenRemoved 中统一使用 deleteLater()
void TreelandOutputWatcher::onScreenRemoved(QScreen *screen)
{
for (auto it = m_uuidToScreen.begin(); it != m_uuidToScreen.end();) {
if (it.value() == screen)
it = m_uuidToScreen.erase(it);
else
++it;
}
if (auto obj = m_uuidRequests.take(screen))
obj->deleteLater(); // 统一使用 deleteLater()
}本报告由 AI 代码审查工具自动生成 |
| shell.cpp | ||
| treelandoutputwatcher.h | ||
| treelandoutputwatcher.cpp | ||
| treelandoutputuuid.h |
There was a problem hiding this comment.
先放osd插件或者搞个库吧,不放在shell里,
Treeland output 协议 v2 适配
将 dde-shell 中两处 treeland output v1 协议消费者迁移到 v2(纯协议消费者迁移,无逻辑变更)。
改动文件(6 个)
shell/CMakeLists.txtfind_package(TreelandProtocols 0.6 REQUIRED);XML 引用 →treeland-output-manager-unstable-v2.xmlshell/treelandoutputwatcher.hqwayland-treeland-output-manager-unstable-v2.h;基类 →treeland_output_manager_v2;override 签名QString→struct ::wl_output*;新增struct wl_output;前置声明shell/treelandoutputwatcher.cpp…-unstable-v2-client-protocol.h;接口版本 →treeland_output_manager_v2_interface.version;primary_output改为 null 早返回 + 遍历qApp->screens()通过QNativeInterface::QWaylandScreen::output()反查 QScreenpanels/notification/osd/brightness/CMakeLists.txtNO_INCLUDE_CORE_ONLY)panels/notification/osd/brightness/treelandbrightness.hcolor_control_v1→picture_control_v2;treeland_output_manager_v1→v2;本地类名TreelandColorControl保留不变panels/notification/osd/brightness/treelandbrightness.cppget_color_control→get_picture_control;接口版本更新关键说明
#include <QNativeInterface>:Qt6 不为该命名空间生成转发头文件,QWaylandScreen通过<QScreen>传递性引入primary_output事件allow-null="true",实现中 null 早返回qApp->primaryScreen()->name()在primaryScreen()返回 null 时会崩溃;v2 版本增加了 null 防护Ref: DDE-232
Multica Issue: DDE-541
Summary by Sourcery
Migrate Treeland output consumers to protocol v2 with UUID-based output identification and robust screen lifecycle handling.
Bug Fixes:
Enhancements:
Build: