feat: support move xembed window on treeland#1573
Conversation
|
Skipping CI for Draft Pull Request. |
18de6a1 to
d0bfc61
Compare
| return false; | ||
| } | ||
|
|
||
| m_ddeShellManager->setXWindowPositionRelative(wid, m_dockWlSurface, dx, dy); |
There was a problem hiding this comment.
此处都是基于 dockWlSurface 进行偏移,是否有考虑托盘在展开区域情况呢?
|
TAG Bot New tag: 2.0.39 |
d0bfc61 to
ebce64c
Compare
|
TAG Bot New tag: 2.0.40 |
|
TAG Bot New tag: 2.0.41 |
|
TAG Bot New tag: 2.0.42 |
ebce64c to
9212ff4
Compare
通过 treeland 提供的 API 移动 xembed 窗口 Log:
9212ff4 to
89a9214
Compare
deepin pr auto review你好!我是CodeGeeX。我已仔细审查了你提交的Git Diff。此次代码变更的主要目的是在Wayland环境下,实现任务栏中XEmbed窗口相对于任务栏表面的移动定位功能,涉及从Wayland协议解析、QML信号传递到C++后端调用的完整链路。 整体来看,代码逻辑清晰,模块划分合理,但在生命周期管理、并发安全、Wayland资源使用规范以及代码性能方面存在一些需要改进的隐患。以下是详细的审查意见: 一、 代码安全1. Wayland资源生命周期悬空指针风险(严重) struct PendingXEmbedCallback {
uint32_t callback;
struct ::wl_resource *resource; // 危险:存储了原始指针
};Wayland客户端可能在请求发出后、回调执行前崩溃或断开连接,此时 2. QML注入与类型校验风险 property var moveXEmbedWindowHandler: null
// ...
if (typeof dockCompositor.moveXEmbedWindowHandler === 'function') {
var success = dockCompositor.moveXEmbedWindowHandler(wid, dx, dy)
if (typeof wid === 'number' && typeof dx === 'number' && typeof dy === 'number') { ... }二、 语法与逻辑1. Wayland回调ID的误用(严重) wl_resource *callbackResource = wl_resource_create(resource->client(), &wl_callback_interface,
1, callback);Wayland协议中, 2. double dx = pluginSurface->itemPosition().x();
double dy = pluginSurface->itemPosition().y();变量名 3. 版权年份的修改 -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd.将版权年份修改为未来的年份(2026)不符合开源规范。版权年份应当是代码首次发表或修改的真实年份。 三、 代码性能1. PluginSurface* PluginManager::findPluginSurface(const QString &pluginId, const QString &itemKey) const
{
for (PluginSurface *plugin : m_pluginSurfaces) {
if (plugin->pluginId() == pluginId && plugin->itemKey() == itemKey) {
return plugin;
}
}
return nullptr;
}每次移动 XEmbed 窗口都会触发一次 四、 代码质量1. 并发请求的潜在逻辑漏洞 2. QML 中的 onMoveXEmbedWindowRequested: (wid, pluginId, itemKey, dx, dy) => {
console.log("move xembed window requested:", wid, pluginId, itemKey, dx, dy)在频繁触发的事件(如窗口移动)中保留 3. struct ::wl_surface *m_dockWlSurface = nullptr;存储 Wayland 核心对象的原始指针同样面临生命周期问题。如果 Dock 窗口因为屏幕变化被销毁重建,这个指针将失效。 综合修改建议示例(针对核心问题):C++ 端 struct PendingXEmbedCallback {
uint32_t callback_id; // 客户端传来的 new_id
struct ::wl_client *client; // 存储客户端指针,而非 resource 指针
uint32_t resource_version; // 记录请求时的版本号
};C++ 端 void PluginManager::plugin_manager_v1_move_xembed_window(Resource *resource, uint32_t xembed_winid, const QString &plugin_id, const QString &item_key, uint32_t callback)
{
// ... 寻找 pluginSurface 逻辑不变 ...
// 记录客户端和版本号
m_pendingXEmbedCallbacks[xembed_winid] = {
callback,
wl_resource_get_client(resource->handle),
wl_resource_get_version(resource->handle)
};
// 注意变量名修改为 posX, posY
double posX = pluginSurface->itemPosition().x();
double posY = pluginSurface->itemPosition().y();
Q_EMIT moveXEmbedWindowRequested(xembed_winid, plugin_id, item_key, posX, posY);
}
void PluginManager::notifyXEmbedWindowMoveResult(uint32_t wid, bool success)
{
if (!m_pendingXEmbedCallbacks.contains(wid)) return;
PendingXEmbedCallback pending = m_pendingXEmbedCallbacks.take(wid);
// 使用存储的 client 和 version 正确创建回调资源
wl_resource *callbackResource = wl_resource_create(
pending.client,
&wl_callback_interface,
pending.resource_version, // 使用正确的版本号
pending.callback_id // 客户端指定的 new_id
);
if (callbackResource) {
wl_callback_send_done(callbackResource, success ? 0 : 1);
wl_resource_destroy(callbackResource);
}
}希望这些审查意见对你有所帮助!如果有任何细节需要进一步讨论,欢迎随时提问。 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: BLumia, justforlxz 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 |
通过 treeland 提供的 API 移动 xembed 窗口。