feat: migrate set_xwindow_position_relative to treeland-xwindow-control-unstable-v1 protocol - #1410
Conversation
|
Skipping CI for Draft Pull Request. |
Reviewer's GuideMigrates set_xwindow_position_relative from the deprecated DDE shell interface to a separately generated and registered treeland-xwindow-control-unstable-v1 server protocol, updates the example client, and adds protocol/Qt tests focused on binding, failure callbacks, and lifecycle behavior. Sequence diagram for relative X window positioningsequenceDiagram
participant Client as Wayland client
participant Control as XWindowControlInterfaceV1
participant Helper
participant Callback as wl_callback
Client->>Control: set_xwindow_position_relative(callback, wid, anchor, dx, dy)
Control->>Helper: setXWindowPositionRelative(wid, wsurface, dx, dy)
Helper-->>Control: success or failure
Control->>Callback: wl_callback_send_done(ok)
Control->>Callback: wl_resource_destroy()
Callback-->>Client: completion callback
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/modules/xwindow-control/xwindowcontrolinterfacev1.cpp" line_range="53-55" />
<code_context>
-{
- WSurface *wsurface = WSurface::fromHandle(wlr_surface_from_resource(anchor));
- uint32_t ok = (wsurface && Helper::instance()->setXWindowPositionRelative(wid, wsurface, dx, dy)) ? 0 : 1;
- wl_resource *cb = wl_resource_create(resource->client(), &wl_callback_interface, 1, callback);
- wl_callback_send_done(cb, ok);
- wl_resource_destroy(cb);
-}
-
</code_context>
<issue_to_address>
**issue (bug_risk):** `wl_resource_create` can return null when the callback resource cannot be allocated, but the code immediately passes that null pointer to `wl_callback_send_done` and then destroys it, causing a compositor crash instead of reporting an allocation failure to the client.
**Triggers:** When a client sends the request while Wayland resource allocation fails.
**Suggested fix:** Check `cb` before sending or destroying it, and call `wl_client_post_no_memory(resource->client())` when allocation fails.
```suggestion
wl_resource *cb = wl_resource_create(resource->client(), &wl_callback_interface, 1, callback);
if (!cb) {
wl_client_post_no_memory(resource->client());
return;
}
wl_callback_send_done(cb, ok);
wl_resource_destroy(cb);
```
</issue_to_address>There was a problem hiding this comment.
🟡 Changes recommended
Unresolved invalid-anchor and callback allocation handling, incomplete success-path coverage, and protocol audit documentation gaps.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Migrates X Window relative positioning to the dedicated treeland-xwindow-control-unstable-v1 protocol.
Changes:
- Adds and registers the new server protocol module.
- Removes the deprecated DDE-shell request and updates the example client.
- Adds Qt and Wayland protocol tests.
File summaries
| File | Reviewed change |
|---|---|
tests/test_protocol_xwindow-control/main.cpp |
Qt interface test coverage. |
tests/test_protocol_xwindow-control/CMakeLists.txt |
Registers the Qt test target. |
tests/protocols/treeland-xwindow-control-unstable-v1/treeland-xwindow-control-unstable-v1.h |
Defines protocol test state. |
tests/protocols/treeland-xwindow-control-unstable-v1/treeland-xwindow-control-unstable-v1.c |
Adds Wayland client coverage; currently exercises failure paths only. |
tests/protocols/treeland-xwindow-control-unstable-v1/setup.cpp |
Connects the production interface for testing. |
tests/protocols/treeland-xwindow-control-unstable-v1/CMakeLists.txt |
Registers the protocol integration test. |
tests/protocols/CMakeLists.txt |
Adds the protocol test directory; audit documentation is still required. |
tests/CMakeLists.txt |
Registers the test directory. |
src/seat/helper.h |
Adds ownership for the new interface. |
src/seat/helper.cpp |
Registers the protocol global during initialization. |
src/modules/xwindow-control/xwindowcontrolinterfacev1.h |
Declares the protocol interface. |
src/modules/xwindow-control/xwindowcontrolinterfacev1.cpp |
Implements requests and callbacks; invalid anchors and callback allocation require handling. |
src/modules/xwindow-control/CMakeLists.txt |
Generates and builds protocol bindings. |
src/modules/dde-shell/ddeshellmanagerinterfacev1.cpp |
Removes the deprecated request implementation. |
src/modules/CMakeLists.txt |
Registers the new module. |
examples/test_set_xwindow_position/main.cpp |
Migrates the example client to the new protocol. |
examples/test_set_xwindow_position/CMakeLists.txt |
Generates the new client bindings. |
Review details
Suppressed comments (1)
tests/protocols/treeland-xwindow-control-unstable-v1/CMakeLists.txt:6
- The protocol-test guidance requires a README and an
INDEX.mdcoverage entry for each target, and every existing full protocol target follows that convention. Registering this target without either file leaves the audit table unaware of the new protocol and still reports the old DDE request as the only uncovered location. Please add the protocol contract/coverage documentation. 协议测试规范要求每个 target 都有 README 和INDEX.md覆盖记录,现有完整协议 target 也都遵循这一约定。当前只注册 target 而没有这两个文件,会让审计表遗漏新协议并继续把旧 DDE 请求列为唯一未覆盖位置。请补充协议契约和覆盖文档。
treeland_add_protocol_test(
NAME treeland_xwindow_control_v1
XML "${TREELAND_PROTOCOLS_DATA_DIR}/treeland-xwindow-control-unstable-v1.xml"
SETUP "${CMAKE_CURRENT_SOURCE_DIR}/setup.cpp"
CLIENT "${CMAKE_CURRENT_SOURCE_DIR}/treeland-xwindow-control-unstable-v1.c"
- Files reviewed: 17/17 changed files
- Comments generated: 4
- Review effort level: Lite
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| wl_fixed_t dx = wl_fixed_from_int(0); | ||
| wl_fixed_t dy = wl_fixed_from_int(0); | ||
| struct wl_callback *cb = | ||
| treeland_xwindow_control_v1_set_xwindow_position_relative(ctx->manager, 0, surface, dx, dy); |
There was a problem hiding this comment.
You are right that the current cases only prove the failure path. A real success path (done(0)) requires a mapped XWayland SurfaceWrapper matching wid, and our protocol tests run with WLR_BACKENDS=headless + WLR_RENDERER=pixman, where Xwayland cannot start (glamor needs GBM Wayland interfaces, unavailable without a GPU — verified locally: Xwayland exits right after startup). Instead of asserting a path that can never execute in CI, the success path is now recorded as the next unverified production result in tests/protocols/treeland-xwindow-control-unstable-v1/README.md, with the required precondition (a runnable Xwayland test environment). The invalid-anchor and OOM guards in the server implementation are also documented there.
…ol-unstable-v1 protocol - Add new xwindow-control module with XWindowControlInterfaceV1 implementing the treeland_xwindow_control_v1 global interface - Register XWindowControlInterfaceV1 in Helper::initShell() - Remove deprecated set_xwindow_position_relative override from DDEShellManagerInterfaceV1Private (now handled by the new module) - Update example to use the new treeland_xwindow_control_v1 client interface - Add protocol integration test and Qt unit test for the new interface
11ab724 to
6078fb8
Compare
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="examples/test_set_xwindow_position/main.cpp" line_range="100" />
<code_context>
wl_fixed_t dy = wl_fixed_from_int(0);
- wl_callback *callback = manager.set_xwindow_position_relative(wid, surface, dx, dy);
+ wl_callback *callback = control.set_xwindow_position_relative(wid, surface, dx, dy);
wl_callback_add_listener(callback, &callback_listener, nullptr);
qWarning() << "Setting xwindow position relative, wait for result...";
</code_context>
<issue_to_address>
**nitpick (bug_risk):** `wl_callback_add_listener(callback, ...)` dereferences a null callback when the server cannot allocate the callback resource and posts `wl_client_post_no_memory()`, so the example crashes instead of handling the failed request or disconnected Wayland connection.
**Triggers:** When the compositor reports callback-resource allocation failure.
**Suggested fix:** Check `callback` before calling `wl_callback_add_listener` and stop using the connection when it is null.
</issue_to_address>…quest Check wl_resource_create result and post no-memory error instead of crashing; guard null anchor resource; document the protocol test contract and record the XWayland success path as a known boundary. 检查 wl_resource_create 结果并在分配失败时上报 no-memory 错误而非 崩溃;守卫空 anchor 资源;补充协议测试契约文档,并将 XWayland 成功 路径记为已知边界。 Log: 修复 xwindow-control 回调分配失败崩溃并补测试文档 Influence: 客户端传入无效 anchor 或回调资源分配失败时合成器不再崩溃, 统一返回失败结果;协议测试新增契约文档与索引条目。
6078fb8 to
bda3001
Compare
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Adapt treeland to the new treeland-xwindow-control-unstable-v1 protocol from treeland-protocols 0.6.0.
Changes
New module: src/modules/xwindow-control/
Modified files
Closes #WM-481
Summary by Sourcery
Migrate relative X window positioning to the treeland-xwindow-control-unstable-v1 protocol while retaining coverage for its failure and lifecycle behavior.
New Features:
Bug Fixes:
Enhancements:
Build:
Documentation:
Tests: