Skip to content

feat: adopt xdg-activation protocol for Treeland dock plugin#566

Merged
18202781743 merged 1 commit into
linuxdeepin:masterfrom
18202781743:master
Jun 17, 2026
Merged

feat: adopt xdg-activation protocol for Treeland dock plugin#566
18202781743 merged 1 commit into
linuxdeepin:masterfrom
18202781743:master

Conversation

@18202781743

@18202781743 18202781743 commented Jun 12, 2026

Copy link
Copy Markdown
Contributor
  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可用并能正确调用以启动控制中心

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:

  • Introduce an XdgActivation helper for requesting XDG activation tokens on Wayland and wire it into dock network UI actions and NetManager flows.
  • Replace direct D-Bus invocations to ControlCenter with dde-am launches that optionally carry XDG activation tokens for proper window focus and page navigation.
  • Extend NetManager threading and IPC parameters to propagate activation tokens when opening ControlCenter from various network entry points.

Build:

  • Update CMake and project configuration to depend on ECM and wayland-protocols, enable Qt Wayland client, and generate xdg-activation client protocol sources.

@sourcery-ai

sourcery-ai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adopts 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 token

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

File-Level Changes

Change Details Files
Introduce an XdgActivation helper around the Wayland xdg-activation-v1 protocol and wire it into network-related UI entry points to request activation tokens before launching ControlCenter via dde-am.
  • Add dde::network::XdgActivation QObject wrapper and internal XdgActivationV1 client extension using QtWayland xdg-activation-v1, requesting tokens based on the focused QWindow and DSGApplication app id
  • Emit a tokenReady signal from XdgActivation once the protocol responds, or an empty token when the extension is inactive, logging detailed diagnostics via QLoggingCategory
  • Use XdgActivation in JumpSettingButton to request a token, build the combined first/second page path, and launch dde-am with --by-user org.deepin.dde.control-center, optional XDG_ACTIVATION_TOKEN, and -p page arguments
dock-network-plugin/xdgactivation.h
dock-network-plugin/xdgactivation.cpp
dock-network-plugin/widget/jumpsettingbutton.cpp
Replace direct D-Bus invocations to ControlCenter with dde-am-based launches that optionally include XDG activation tokens and pass explicit network page paths.
  • Change NetworkPlugin::itemCommand to return a dde-am command line targeting org.deepin.dde.control-center with -p network instead of dbus-send ShowModule
  • Update NetworkDBusProxy::ShowPage to spawn dde-am with --by-user org.deepin.dde.control-center and -p url instead of sending org.deepin.dde.ControlCenter1.ShowPage over QDBus
  • Refactor NetManager/NetManagerThreadPrivate to accept an optional activation token, marshal it through exec parameters, and in doGotoControlCenter construct a network[/subpage] path and launch dde-am with optional XDG_ACTIVATION_TOKEN
dock-network-plugin/networkplugin.cpp
common-plugin/networkdialog/networkdbusproxy.cpp
net-view/operation/netmanager.h
net-view/operation/netmanager.cpp
net-view/operation/private/netmanagerthreadprivate.h
net-view/operation/private/netmanagerthreadprivate.cpp
Ensure all UI paths that navigate to ControlCenter from the dock/network UI obtain and pass activation tokens on Wayland, preserving focus and page navigation.
  • Wrap DockContentWidget network settings button click handler with an XdgActivation request that calls NetManager::gotoControlCenter(token) when ready
  • Update NetworkPlugin quick icon and quick panel click handlers to request an activation token via XdgActivation and forward it to NetManager::gotoControlCenter(token)
  • Preserve existing behavior for toggling/toggling network state or showing dialogs when ControlCenter is not needed, while integrating token-based launches where applicable
dock-network-plugin/dockcontentwidget.h
dock-network-plugin/networkplugin.cpp
Extend the CMake build and dependencies to support Wayland xdg-activation client code generation and Qt Wayland usage in the dock network plugin.
  • Add ECM and WaylandProtocols discovery in the top-level CMakeLists.txt and append ECM_MODULE_PATH to CMAKE_MODULE_PATH
  • Update dock-network-plugin CMakeLists to include xdgactivation sources, require Qt WaylandClient, link against Qt WaylandClientPrivate, and include the current binary dir for generated headers
  • Use qt_generate_wayland_protocol_client_sources with the staging xdg-activation-v1.xml to generate the client-side protocol classes at build time
CMakeLists.txt
dock-network-plugin/CMakeLists.txt
Minor maintenance and copyright updates accompanying the feature.
  • Update SPDX copyright year ranges in several source files to extend through 2026
  • Include additional Qt and STL headers (QProcess) where needed to support dde-am process launching
dock-network-plugin/widget/jumpsettingbutton.cpp
dock-network-plugin/networkplugin.cpp
common-plugin/networkdialog/networkdbusproxy.cpp
net-view/operation/private/netmanagerthreadprivate.cpp
src/impl/serviceinter/deviceinterrealize.cpp
dock-network-plugin/CMakeLists.txt
common-plugin/networkdialog/networkdbusproxy.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

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

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread dock-network-plugin/dockcontentwidget.h
mhduiy
mhduiy previously approved these changes Jun 12, 2026
Comment thread common-plugin/networkdialog/networkdbusproxy.cpp Outdated
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);

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.

这里有重复代码,建议在NetworkPlugin里加个函数,DockContentWidget里加个信号,NetworkPlugin里调用函数

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

这个不加函数吧,本身也是简单的组合,它跟NetworkPlugin也没有公共的东西,

Comment thread dock-network-plugin/networkplugin.cpp Outdated
caixr23
caixr23 previously approved these changes Jun 16, 2026
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-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:80分

■ 【总体评价】

代码成功引入XDG Activation协议解决了Wayland下窗口激活问题,但存在严重的代码重复和局部逻辑缺陷
逻辑基本正确但因重复代码过多扣10分,早返回未发信号扣10分

■ 【详细分析】

  • 1.语法逻辑 基本正确 ✓

在XdgActivation::requestToken函数中,当m_provider非空时会直接返回,但未发射tokenReady信号。这会导致调用方(如onQuickIconClicked中的lambda)永远无法执行deleteLater,造成XdgActivation对象泄漏及悬垂信号槽连接。在NetworkPlugin::itemCommand函数中,直接返回了不带XDG_ACTIVATION_TOKEN的dde-am命令字符串,导致通过此同步接口调用时依然无法在Wayland下正确激活控制中心窗口。
潜在问题:m_provider非空时信号丢失导致对象泄漏;itemCommand路径在Wayland下失效
建议:在m_provider非空判断分支中补充Q_EMIT tokenReady({});评估itemCommand的调用场景并增加注释说明其Wayland下的局限性

  • 2.代码质量 存在严重问题 ✕

获取Token并启动控制中心的异步代码模式在dockcontentwidget.h、networkplugin.cpp的onQuickIconClicked、onQuickPanelClicked以及jumpsettingbutton.cpp中高度重复。同时,拼装dde-am启动参数并调用QProcess::startDetached的逻辑在jumpsettingbutton.cpp和netmanagerthreadprivate.cpp的doGotoControlCenter中完全重复。xdgactivation.cpp中包含大量qCDebug日志,在生产环境中可能产生不必要的I/O开销。
潜在问题:同质化代码块达4处,启动逻辑重复2处,维护成本极高且易引入不一致缺陷
建议:将请求Token与启动控制中心的逻辑下沉封装为NetManager的一个异步方法,消除上层的重复Lambda;将dde-am启动逻辑统一收敛到doGotoControlCenter中,jumpsettingbutton仅调用NetManager接口

  • 3.代码性能 无性能问题 ✓

虽然每次点击都会new XdgActivation对象,但通过Qt父子对象机制和deleteLater能够保证及时回收。XdgActivationV1单例采用QPointer管理,避免了全局静态常驻内存。Wayland协议交互本身为异步IPC,不涉及阻塞等待。
建议:无

  • 4.代码安全 存在0个安全漏洞 ✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
代码中所有启动外部进程的操作均严格使用QProcess::startDetached的重载形式,将命令和参数作为QStringList分离传递。这种调用方式底层直接映射为execvp系统调用,彻底杜绝了通过拼接字符串导致的Shell命令注入风险。传入的token和page参数均被作为独立实体处理,无法逃逸为命令分隔符或子命令。
建议:无

■ 【改进建议代码示例】

// 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);
}

@18202781743 18202781743 requested review from caixr23 and mhduiy June 16, 2026 13:02
@deepin-ci-robot

Copy link
Copy Markdown

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

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

@18202781743 18202781743 merged commit 7c0b18c into linuxdeepin:master Jun 17, 2026
17 of 19 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.

4 participants