Skip to content

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

Draft
deepin-wm wants to merge 1 commit into
linuxdeepin:masterfrom
deepin-wm:agent/developer/a38088999aa5
Draft

deepin-wm wants to merge 1 commit 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.

New Features:

  • Add the treeland-xwindow-control-unstable-v1 protocol for relative X window positioning and register it with the compositor.
  • Provide protocol examples and integration coverage for binding, requests, callbacks, and resource destruction.

Enhancements:

  • Remove relative X window positioning from the deprecated DDE shell protocol.

Build:

  • Add the new X window control module and protocol generation to the build.

Tests:

  • Add Wayland protocol integration and Qt unit tests for the X window control interface.

@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

@deepin-ci-robot

Copy link
Copy Markdown

[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.

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

@sourcery-ai

sourcery-ai Bot commented Sep 15, 2026

Copy link
Copy Markdown

Reviewer's Guide

Migrates relative X window positioning from the deprecated DDE shell interface to a dedicated treeland-xwindow-control-unstable-v1 global, including server registration, example-client updates, protocol generation, and integration/unit coverage.

Sequence diagram for relative X window positioning via the new protocol

sequenceDiagram
    participant Client
    participant XWindowControl as treeland_xwindow_control_v1
    participant Helper
    participant Callback as wl_callback

    Client->>XWindowControl: set_xwindow_position_relative(callback, wid, anchor, dx, dy)
    XWindowControl->>Helper: setXWindowPositionRelative(wid, wsurface, dx, dy)
    XWindowControl->>Callback: wl_callback_send_done(ok)
    XWindowControl->>Callback: wl_resource_destroy()
Loading

File-Level Changes

Change Details Files
Introduces and registers a compositor-side X window control protocol implementation for relative X window positioning.
  • Generates the server bindings from treeland-xwindow-control-unstable-v1.xml.
  • Implements protocol resource destruction and relative-position requests, delegating to Helper and returning a wl_callback status.
  • Attaches the interface during shell initialization and stores it in Helper.
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 request override and its Helper/WSurface-based implementation.
  • Retains the DDE shell interface for its remaining requests.
src/modules/dde-shell/ddeshellmanagerinterfacev1.cpp
Migrates the example client to the new X window control protocol.
  • Generates and includes the new client bindings.
  • Renames the client extension and routes requests through treeland_xwindow_control_v1.
examples/test_set_xwindow_position/CMakeLists.txt
examples/test_set_xwindow_position/main.cpp
Adds protocol and Qt coverage for the new interface.
  • Adds protocol test setup and client coverage for binding, request handling, failure callback, and manager destruction.
  • Adds a Qt test covering interface creation and discovery.
tests/CMakeLists.txt
tests/protocols/CMakeLists.txt
tests/protocols/treeland-xwindow-control-unstable-v1/CMakeLists.txt
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 on lines +53 to +55
wl_resource *cb = wl_resource_create(resource->client(), &wl_callback_interface, 1, callback);
wl_callback_send_done(cb, ok);
wl_resource_destroy(cb);

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): 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.

Suggested change
wl_resource *cb = wl_resource_create(resource->client(), &wl_callback_interface, 1, callback);
wl_callback_send_done(cb, ok);
wl_resource_destroy(cb);
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);

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

wl_fixed_t dx,
wl_fixed_t dy)
{
WSurface *wsurface = WSurface::fromHandle(wlr_surface_from_resource(anchor));
Comment on lines +53 to +55
wl_resource *cb = wl_resource_create(resource->client(), &wl_callback_interface, 1, callback);
wl_callback_send_done(cb, ok);
wl_resource_destroy(cb);
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);
add_subdirectory(treeland-wallpaper-shell-unstable-v1)
add_subdirectory(treeland-wallpaper-desktop-v1)
add_subdirectory(treeland-show-desktop-v1)
add_subdirectory(treeland-xwindow-control-unstable-v1)
…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 from 14b6f82 to f6c629c Compare September 16, 2026 02:14
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.

4 participants