Repository navigation
feat: migrate set_xwindow_position_relative to treeland-xwindow-control-unstable-v1 protocol #1410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
zccrs
merged 2 commits into
linuxdeepin:master
from
deepin-wm:agent/developer/a38088999aa5
Sep 16, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| find_package(TreelandProtocols REQUIRED) | ||
|
|
||
| waylib_generate_qtwayland_server_protocol(libtreeland | ||
| PROTOCOL ${TREELAND_PROTOCOLS_DATA_DIR}/treeland-xwindow-control-unstable-v1.xml | ||
| BASENAME treeland-xwindow-control-unstable-v1 | ||
| ) | ||
|
|
||
| impl_treeland( | ||
| NAME | ||
| module_xwindow_control | ||
| SOURCE | ||
| ${CMAKE_SOURCE_DIR}/src/modules/xwindow-control/xwindowcontrolinterfacev1.h | ||
| ${CMAKE_SOURCE_DIR}/src/modules/xwindow-control/xwindowcontrolinterfacev1.cpp | ||
| LINK | ||
| Wlroots::wlroots | ||
| Waylib::WaylibServer | ||
| Qt6::Core | ||
| Qt6::Gui | ||
| Qt6::Quick | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| // Copyright (C) 2026 UnionTech Software Technology Co., Ltd. | ||
| // SPDX-License-Identifier: Apache-2.0 OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only | ||
|
|
||
| #include "xwindowcontrolinterfacev1.h" | ||
| #include "qwayland-server-treeland-xwindow-control-unstable-v1.h" | ||
|
|
||
| #include "seat/helper.h" | ||
|
|
||
| #include <wserver.h> | ||
| #include <wsurface.h> | ||
|
|
||
| #include <wayland-server-core.h> | ||
|
|
||
| #include <cstring> | ||
|
|
||
| class XWindowControlInterfaceV1Private : public QtWaylandServer::treeland_xwindow_control_v1 | ||
| { | ||
| public: | ||
| XWindowControlInterfaceV1Private(XWindowControlInterfaceV1 *_q); | ||
| wl_global *global() const; | ||
|
|
||
| XWindowControlInterfaceV1 *q; | ||
|
|
||
| protected: | ||
| void destroy(Resource *resource) override; | ||
| void set_xwindow_position_relative(Resource *resource, uint32_t callback, uint32_t wid, | ||
| struct ::wl_resource *anchor, wl_fixed_t dx, wl_fixed_t dy) override; | ||
| }; | ||
|
|
||
| XWindowControlInterfaceV1Private::XWindowControlInterfaceV1Private(XWindowControlInterfaceV1 *_q) | ||
| : QtWaylandServer::treeland_xwindow_control_v1() | ||
| , q(_q) | ||
| { | ||
| } | ||
|
|
||
| wl_global *XWindowControlInterfaceV1Private::global() const | ||
| { | ||
| return m_global; | ||
| } | ||
|
|
||
| void XWindowControlInterfaceV1Private::destroy(Resource *resource) | ||
| { | ||
| wl_resource_destroy(resource->handle); | ||
| } | ||
|
|
||
| void XWindowControlInterfaceV1Private::set_xwindow_position_relative(Resource *resource, | ||
| uint32_t callback, | ||
| uint32_t wid, | ||
| struct ::wl_resource *anchor, | ||
| wl_fixed_t dx, | ||
| wl_fixed_t dy) | ||
| { | ||
| WSurface *wsurface = nullptr; | ||
| if (anchor && strcmp(wl_resource_get_class(anchor), "wl_surface") == 0) | ||
| 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); | ||
| if (!cb) { | ||
| wl_client_post_no_memory(resource->client()); | ||
| return; | ||
| } | ||
| wl_callback_send_done(cb, ok); | ||
| wl_resource_destroy(cb); | ||
|
sourcery-ai[bot] marked this conversation as resolved.
|
||
| } | ||
|
|
||
| XWindowControlInterfaceV1::XWindowControlInterfaceV1(QObject *parent) | ||
| : QObject(parent) | ||
| , d(new XWindowControlInterfaceV1Private(this)) | ||
| { | ||
| } | ||
|
|
||
| XWindowControlInterfaceV1::~XWindowControlInterfaceV1() = default; | ||
|
|
||
| void XWindowControlInterfaceV1::create(WServer *server) | ||
| { | ||
| d->init(server->handle(), InterfaceVersion); | ||
| } | ||
|
|
||
| void XWindowControlInterfaceV1::destroy([[maybe_unused]] WServer *server) | ||
| { | ||
| d->globalRemove(); | ||
| } | ||
|
|
||
| wl_global *XWindowControlInterfaceV1::global() const | ||
| { | ||
| return d->global(); | ||
| } | ||
|
|
||
| QByteArrayView XWindowControlInterfaceV1::interfaceName() const | ||
| { | ||
| return d->interfaceName(); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| // Copyright (C) 2026 UnionTech Software Technology Co., Ltd. | ||
| // SPDX-License-Identifier: Apache-2.0 OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <wserver.h> | ||
|
|
||
| #include <QQmlEngine> | ||
|
|
||
| WAYLIB_SERVER_USE_NAMESPACE | ||
|
|
||
| class XWindowControlInterfaceV1Private; | ||
| class XWindowControlInterfaceV1 | ||
| : public QObject | ||
| , public WAYLIB_SERVER_NAMESPACE::WServerInterface | ||
| { | ||
| Q_OBJECT | ||
|
|
||
| public: | ||
| explicit XWindowControlInterfaceV1(QObject *parent = nullptr); | ||
| ~XWindowControlInterfaceV1() override; | ||
|
|
||
| QByteArrayView interfaceName() const override; | ||
|
|
||
| static constexpr int InterfaceVersion = 1; | ||
|
|
||
| protected: | ||
| void create(WServer *server) override; | ||
| void destroy(WServer *server) override; | ||
| wl_global *global() const override; | ||
|
|
||
| private: | ||
| std::unique_ptr<XWindowControlInterfaceV1Private> d; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
tests/protocols/treeland-xwindow-control-unstable-v1/CMakeLists.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
|
|
||
| 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" | ||
| ) |
40 changes: 40 additions & 0 deletions
40
tests/protocols/treeland-xwindow-control-unstable-v1/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # `treeland-xwindow-control-unstable-v1` 测试规范 | ||
|
|
||
| ## 范围 | ||
|
|
||
| - XML / interface:`treeland_xwindow_control_v1`(v1) | ||
| - 测试源码:`tests/protocols/treeland-xwindow-control-unstable-v1/` | ||
| - Fixture:`protocol_test_setup` 注册生产 `XWindowControlInterfaceV1` 全局并创建 | ||
| headless output(仅协议/资源级,无需 mapped 窗口) | ||
| - 覆盖等级:**P** | ||
|
|
||
| ## 必须观察到的结果 | ||
|
|
||
| | 场景 | 客户端动作 | 必须观察到的结果 | 证据层级 | | ||
| | --- | --- | --- | --- | | ||
| | 初始化 | bind `treeland_xwindow_control_v1` | manager 非空 | P | | ||
| | 请求(失败) | `set_xwindow_position_relative`,anchor 为无对应 `SurfaceWrapper` 的裸 `wl_surface`、wid=0 | `wl_callback.done(1)` | P | | ||
| | 资源销毁 | `destroy` | 资源销毁,无协议错误 | P | | ||
|
|
||
| ## 生产结果 | ||
|
|
||
| `set_xwindow_position_relative` 在服务端解析 anchor `wl_surface` 为 `WSurface`,再交给 | ||
| `Helper::setXWindowPositionRelative(wid, wsurface, dx, dy)`。失败路径测试证明:当 anchor | ||
| `wl_surface` 没有 `SurfaceWrapper`(裸 surface)且 wid 为 0 时,`Helper` 返回 false, | ||
| 服务端把结果 `1` 通过新建的 `wl_callback` 回传并销毁该 callback。 | ||
|
|
||
| `XWindowControlInterfaceV1Private` 在 `wl_resource_create` 分配 callback 失败时会调用 | ||
| `wl_client_post_no_memory` 并中止该请求,避免对 null callback 解引用导致合成器崩溃;该 | ||
| OOM 分支不在测试中强制触发(无法稳定注入 Wayland 内存分配失败)。 | ||
|
|
||
| ## 已知边界 / 下一项结果 | ||
|
|
||
| - **成功路径(callback.done(0))未覆盖**:`Helper::setXWindowPositionRelative` 要求 anchor | ||
| 拥有真实 `SurfaceWrapper`,且 wid 匹配一个已映射的 `Type::XWayland` `SurfaceWrapper`。 | ||
| 生成一个真实的 XWayland 窗口需要可用的 Xwayland 实例;treeland 协议测试在 | ||
| `WLR_BACKENDS=headless`、`WLR_RENDERER=pixman` 下运行,Xwayland 启动时 glamor 需要 | ||
| GBM Wayland 接口,无 GPU 环境下无法启动,因此无法在当前 CI 中产出 XWayland | ||
| `SurfaceWrapper`。成功路径(wid 匹配、目标位置 == anchor.topLeft + (dx,dy))作为下一项 | ||
| 待验证结果,前提是具备可运行的 Xwayland 测试环境(GPU 或软件 glamor)。 | ||
| - 无效 anchor(客户端传入 null 或非 `wl_surface` 对象)已被服务端守卫为失败结果 | ||
| (`callback.done(1)`),但未单列为测试用例;可在具备成功路径环境后补充错误注入用例。 |
13 changes: 13 additions & 0 deletions
13
tests/protocols/treeland-xwindow-control-unstable-v1/setup.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // Copyright (C) 2026 UnionTech Software Technology Co., Ltd. | ||
| // SPDX-License-Identifier: Apache-2.0 OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only | ||
| #include "modules/xwindow-control/xwindowcontrolinterfacev1.h" | ||
| #include "server-bridge.h" | ||
|
|
||
| #include <wserver.h> | ||
|
|
||
| WAYLIB_SERVER_USE_NAMESPACE | ||
|
|
||
| void protocol_test_setup(Helper *helper) | ||
| { | ||
| find_server_interface<XWindowControlInterfaceV1>(helper); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.