feat: adopt xdg-activation protocol for Treeland dock plugin#566
Conversation
Reviewer's GuideAdopts the Wayland xdg-activation-v1 protocol in the Treeland dock network plugin, introducing an XdgActivation helper, routing all ControlCenter launches through dde-am with optional activation tokens, and updating the build system and dependencies to generate and link the Wayland client protocol code. Sequence diagram for ControlCenter launch with XDG activation tokensequenceDiagram
actor User
participant DockNetworkUI as DockContentWidget
participant XdgActivation as XdgActivation
participant NetManager as NetManager
participant NetMgrThread as NetManagerThreadPrivate
participant dde_am
participant ControlCenter
User->>DockNetworkUI: click network settings
DockNetworkUI->>XdgActivation: requestToken(window, appId)
XdgActivation-->>DockNetworkUI: tokenReady(token)
DockNetworkUI->>NetManager: gotoControlCenter(token)
NetManager->>NetMgrThread: gotoControlCenter(page, token)
NetMgrThread->>NetMgrThread: doGotoControlCenter(page, token)
NetMgrThread->>dde_am: QProcess::startDetached("dde-am", args{XDG_ACTIVATION_TOKEN})
dde_am-->>ControlCenter: launch with -p network[/page]
ControlCenter-->>User: focused ControlCenter window opened
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="dock-network-plugin/dockcontentwidget.h" line_range="49-50" />
<code_context>
m_netSetBtn->setIcon(QIcon::fromTheme("network-setting"));
m_netSetBtn->setDescription(tr("Network settings"));
- connect(m_netSetBtn, &JumpSettingButton::clicked, netManager, &NetManager::gotoControlCenter);
+ connect(m_netSetBtn, &JumpSettingButton::clicked, this, [this, netManager]() {
+ auto *activation = new XdgActivation(this);
+ connect(activation, &XdgActivation::tokenReady, this,
+ [netManager, activation](const QString &token) {
</code_context>
<issue_to_address>
**issue (bug_risk):** Qualify XdgActivation with its namespace to avoid unresolved symbol / ambiguity
`XdgActivation` is defined in the `dde::network` namespace in `xdgactivation.h`, but here it’s used without qualification or a `using` directive. This can cause a compile error or resolve to the wrong symbol. Use `dde::network::XdgActivation` here (or add an explicit `using` in the relevant scope).
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| m_netSetBtn->setDescription(tr("Network settings")); | ||
| connect(m_netSetBtn, &JumpSettingButton::clicked, netManager, &NetManager::gotoControlCenter); | ||
| connect(m_netSetBtn, &JumpSettingButton::clicked, this, [this, netManager]() { | ||
| auto *activation = new XdgActivation(this); |
There was a problem hiding this comment.
这里有重复代码,建议在NetworkPlugin里加个函数,DockContentWidget里加个信号,NetworkPlugin里调用函数
There was a problem hiding this comment.
这个不加函数吧,本身也是简单的组合,它跟NetworkPlugin也没有公共的东西,
1. Add xdg-activation-v1 protocol support in dock-network-plugin 2. Implement XdgActivation class to request activation tokens via Wayland 3. Replace all direct D-Bus calls to ControlCenter with dde-am + activation token 4. Replace DDBusSender in JumpSettingButton with token-based activation 5. Update NetManager to pass activation token when opening ControlCenter 6. Add necessary dependencies: extra-cmake-modules, wayland-protocols, qt6-wayland-dev 7. Update CMake build system to generate xdg-activation client protocol code Log: 适配Treeland窗口管理器的XDG激活协议,确保从任务栏网络插件打开控制中 心时正确传递激活令牌并获得焦点 Influence: 1. Test clicking network settings button in dock - verify ControlCenter opens with proper focus 2. Test clicking network icon quick panel - verify ControlCenter opens correctly 3. Test clicking network status indicator - verify ControlCenter launches properly 4. Test JumpSettingButton with auto-show-page - verify page navigation works with token 5. Test on X11 environment - verify fallback behavior without activation token 6. Test on Treeland/Wayland - verify XDG activation token is properly generated and passed 7. Test opening ControlCenter from network detail pages - verify correct sub-page navigation 8. Verify dde-am is available and properly invoked for launching ControlCenter feat: 适配Treeland的XDG激活协议 1. 在dock-network-plugin中添加xdg-activation-v1协议支持 2. 实现XdgActivation类,通过Wayland请求激活令牌 3. 将所有直接调用控制中心的D-Bus调用替换为使用dde-am + 激活令牌 4. 替换JumpSettingButton中的DDBusSender为基于令牌的激活方式 5. 更新NetManager以在打开控制中心时传递激活令牌 6. 添加必要依赖:extra-cmake-modules, wayland-protocols, qt6-wayland-dev 7. 更新CMake构建系统以生成xdg-activation客户端协议代码 Log: 适配Treeland窗口管理器的XDG激活协议,确保从任务栏网络插件打开控制中 心时正确传递激活令牌并获得焦点 Influence: 1. 测试点击任务栏网络设置按钮 - 验证控制中心能正确打开并获取焦点 2. 测试点击网络图标快速面板 - 验证控制中心正确打开 3. 测试点击网络状态指示器 - 验证控制中心正常启动 4. 测试JumpSettingButton的自动跳转页面功能 - 验证带令牌的页面导航正常 5. 在X11环境测试 - 验证无激活令牌时的降级处理 6. 在Treeland/Wayland环境测试 - 验证XDG激活令牌正确生成和传递 7. 测试从网络详情页面打开控制中心 - 验证正确的子页面导航 8. 验证dde-am可用并能正确调用以启动控制中心
deepin pr auto review★ 总体评分:80分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // xdgactivation.cpp - 修复信号丢失逻辑
void XdgActivation::requestToken(QWindow *window, const QString &appId)
{
if (m_provider) {
qCWarning(trayXdgActivation) << "XDG activation token request already started, ignoring";
Q_EMIT tokenReady({}); // 修复:补充发射空信号防止调用方泄漏
return;
}
if (!isActive()) {
qCDebug(trayXdgActivation) << "xdg_activation_v1 is not active; token request skipped";
Q_EMIT tokenReady({});
return;
}
// ... 其余逻辑保持不变
}
// networkplugin.h - 新增统一接口消除重复代码
public Q_SLOTS:
void gotoControlCenterAsync();
// networkplugin.cpp - 实现统一接口
void NetworkPlugin::gotoControlCenterAsync()
{
auto *activation = new XdgActivation(this);
connect(activation, &XdgActivation::tokenReady, this,
[this, activation](const QString &token) {
m_manager->gotoControlCenter(token);
activation->deleteLater();
}, Qt::SingleShotConnection);
activation->requestToken();
}
// networkplugin.cpp - 调用方简化为单行调用
void NetworkPlugin::onQuickIconClicked()
{
if (m_netStatus->needShowControlCenter()) {
gotoControlCenterAsync(); // 消除重复Lambda
} else {
m_netStatus->toggleNetworkActive();
}
}
// jumpsettingbutton.cpp - 移除重复的进程启动逻辑,统一走NetManager
void JumpSettingButton::mouseReleaseEvent(QMouseEvent* event)
{
if (underMouse()) {
Q_EMIT clicked();
if (m_autoShowPage && !m_fistPage.isEmpty()) {
QString page = m_fistPage;
if (!m_secondPage.isEmpty())
page += "/" + m_secondPage;
// 复用统一接口,由底层doGotoControlCenter处理具体启动细节
auto *activation = new dde::network::XdgActivation(this);
connect(activation, &dde::network::XdgActivation::tokenReady, this,
[this, activation, page](const QString &token) {
Q_EMIT requestGotoControlCenter(page, token);
activation->deleteLater();
}, Qt::SingleShotConnection);
activation->requestToken();
Q_EMIT showPageRequestWasSended();
}
return;
}
QWidget::mouseReleaseEvent(event);
} |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, caixr23 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 |
Wayland
activation token
qt6-wayland-dev
code
Log: 适配Treeland窗口管理器的XDG激活协议,确保从任务栏网络插件打开控制中
心时正确传递激活令牌并获得焦点
Influence:
opens with proper focus
correctly
launches properly
works with token
token
generated and passed
sub-page navigation
ControlCenter
feat: 适配Treeland的XDG激活协议
Log: 适配Treeland窗口管理器的XDG激活协议,确保从任务栏网络插件打开控制中
心时正确传递激活令牌并获得焦点
Influence:
Summary by Sourcery
Adopt the Wayland xdg-activation-v1 protocol in the dock network plugin and related network components to launch ControlCenter via dde-am with activation tokens, updating build and dependencies accordingly.
Enhancements:
Build: