Skip to content

feat: migrate set_xwindow_position_relative to treeland-xwindow-control-unstable-v1 protocol - #1410

Merged
zccrs merged 2 commits into
linuxdeepin:masterfrom
deepin-wm:agent/developer/a38088999aa5
Sep 16, 2026
Merged

zccrs merged 2 commits into
linuxdeepin:masterfrom
deepin-wm:agent/developer/a38088999aa5

Conversation

@deepin-wm

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

Copy link
Copy Markdown
Contributor

Adapt treeland to the new treeland-xwindow-control-unstable-v1 protocol from treeland-protocols 0.6.0.

Changes

New module: src/modules/xwindow-control/

  • CMakeLists.txt — references treeland-xwindow-control-unstable-v1.xml via waylib_generate_qtwayland_server_protocol
  • xwindowcontrolinterfacev1.h — XWindowControlInterfaceV1 class (QObject + WServerInterface)
  • xwindowcontrolinterfacev1.cpp — XWindowControlInterfaceV1Private implementing treeland_xwindow_control_v1, overrides destroy and set_xwindow_position_relative (calls Helper::instance()->setXWindowPositionRelative(), returns result via wl_callback)

Modified files

  • src/modules/CMakeLists.txt — add_subdirectory(xwindow-control)
  • src/seat/helper.h — add include and m_xWindowControlInterfaceV1 member
  • src/seat/helper.cpp — register XWindowControlInterfaceV1 in initShell()
  • src/modules/dde-shell/ddeshellmanagerinterfacev1.cpp — remove deprecated set_xwindow_position_relative override
  • examples/test_set_xwindow_position/ — updated to use new treeland_xwindow_control_v1 client interface
  • tests/ — added protocol integration test and Qt unit test

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:

  • Add the treeland-xwindow-control-unstable-v1 server interface for relative X window positioning.
  • Expose the new protocol globally and provide an updated example client.

Bug Fixes:

  • Return failure callbacks safely for invalid surfaces or callback allocation failures.

Enhancements:

  • Remove set_xwindow_position_relative from the deprecated DDE shell interface.

Build:

  • Register the new X window control module and protocol-generated sources.

Documentation:

  • Document protocol coverage and the current limitation that successful Xwayland positioning is not tested in CI.

Tests:

  • Add protocol integration and Qt tests covering binding, failure callbacks, and resource destruction.

@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 15, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Migrates 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 positioning

sequenceDiagram
    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
Loading

File-Level Changes

Change Details Files
Introduces and registers a dedicated unstable v1 Wayland server interface for relative X window positioning.
  • Generates the server protocol module from treeland-protocols 0.6.0.
  • Implements interface lifecycle, anchor validation, Helper delegation, success/failure callback reporting, and callback allocation error handling.
  • Attaches the interface during seat initialization.
src/modules/xwindow-control/CMakeLists.txt
src/modules/xwindow-control/xwindowcontrolinterfacev1.h
src/modules/xwindow-control/xwindowcontrolinterfacev1.cpp
src/modules/CMakeLists.txt
src/seat/helper.h
src/seat/helper.cpp
Removes relative X window positioning from the deprecated DDE shell protocol.
  • Deletes the DDE shell request override and its Helper/WSurface implementation.
  • Updates protocol coverage documentation to associate the request with the new interface.
src/modules/dde-shell/ddeshellmanagerinterfacev1.cpp
tests/protocols/INDEX.md
Migrates the example client to the new X window control protocol.
  • Generates client bindings for treeland-xwindow-control-unstable-v1.
  • Renames the client extension and invokes the request through the new interface.
examples/test_set_xwindow_position/CMakeLists.txt
examples/test_set_xwindow_position/main.cpp
Adds protocol and Qt coverage for the new interface.
  • Adds a protocol fixture covering binding, failed positioning callbacks, and resource destruction.
  • Adds protocol documentation and build registration.
  • Adds a Qt test for interface creation and registration.
tests/CMakeLists.txt
tests/protocols/CMakeLists.txt
tests/protocols/treeland-xwindow-control-unstable-v1/CMakeLists.txt
tests/protocols/treeland-xwindow-control-unstable-v1/README.md
tests/protocols/treeland-xwindow-control-unstable-v1/setup.cpp
tests/protocols/treeland-xwindow-control-unstable-v1/treeland-xwindow-control-unstable-v1.c
tests/protocols/treeland-xwindow-control-unstable-v1/treeland-xwindow-control-unstable-v1.h
tests/test_protocol_xwindow-control/CMakeLists.txt
tests/test_protocol_xwindow-control/main.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-wm
deepin-wm marked this pull request as ready for review September 15, 2026 13:53

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

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

Comment thread src/modules/xwindow-control/xwindowcontrolinterfacev1.cpp
@wineee
wineee requested a lite review from Copilot September 16, 2026 01:38
@wineee
wineee marked this pull request as draft September 16, 2026 01:39

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 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.md coverage 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.

Comment thread src/modules/xwindow-control/xwindowcontrolinterfacev1.cpp Outdated
Comment thread src/modules/xwindow-control/xwindowcontrolinterfacev1.cpp
Comment on lines +107 to +110
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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Comment thread tests/protocols/CMakeLists.txt
…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
@wineee
wineee force-pushed the agent/developer/a38088999aa5 branch 2 times, most recently from 11ab724 to 6078fb8 Compare September 16, 2026 03:08
@wineee
wineee marked this pull request as ready for review September 16, 2026 05:08

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

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

Comment thread examples/test_set_xwindow_position/main.cpp
wineee
wineee previously approved these changes Sep 16, 2026
…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 或回调资源分配失败时合成器不再崩溃,
统一返回失败结果;协议测试新增契约文档与索引条目。
@wineee
wineee force-pushed the agent/developer/a38088999aa5 branch from 6078fb8 to bda3001 Compare September 16, 2026 05:15
@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

@zccrs
zccrs merged commit 6e07f58 into linuxdeepin:master Sep 16, 2026
7 checks passed
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