Skip to content

feat: replace internal XdgActivation implementation with Dde::Shell#779

Open
18202781743 wants to merge 1 commit into
linuxdeepin:masterfrom
18202781743:master
Open

feat: replace internal XdgActivation implementation with Dde::Shell#779
18202781743 wants to merge 1 commit into
linuxdeepin:masterfrom
18202781743:master

Conversation

@18202781743

Copy link
Copy Markdown
Contributor
  1. Remove the custom xdg-activation-v1 Wayland protocol implementation
    from ddeintegration
  2. Replace it with the standard Dde::Shell XdgActivation API from
    libdde-shell-dev >= 2.0.45
  3. Remove conditional compilation guards HAVE_WAYLAND_XDG_ACTIVATION
    used to check Wayland platform availability
  4. Update build dependencies: delete wayland-protocols from Build-
    Depends and bump libdde-shell-dev minimum version to 2.0.45, requiring
    DDEShell via find_package.
  5. Refactor DesktopIntegration::launchByDesktopId() to use async token
    request via ds::XdgActivation signal instead of blocking event loop
    with timeout
  6. Fix bug: move LauncherController.visible = false after
    launchByDesktopId() in launcheritem.qml to ensure the launcher hides
    after launch completes

Log: Replaced internal XDG activation implementation with Dde::Shell
library

Influence:

  1. Verify apps launched from launcher raise their windows correctly
    (focus-stealing prevention)
  2. Test that launcher hides after launching an app
  3. Ensure backward compatibility on X11 platforms
  4. Check that token requests don't block the main thread
  5. Verify the build succeeds with the updated libdde-shell-dev version
  6. Test on Wayland with compositors that do not advertise
    xdg_activation_v1

feat: 使用 Dde::Shell 替换内部 XdgActivation 实现

  1. 移除 ddeintegration 中自定义的 xdg-activation-v1 Wayland 协议实现
  2. 替换为 libdde-shell-dev >= 2.0.45 的标准 Dde::Shell XdgActivation API
  3. 移除用于检测 Wayland 平台可用性的条件编译宏
    HAVE_WAYLAND_XDG_ACTIVATION
  4. 更新构建依赖:从 Build-Depends 中删除 wayland-protocols,将 libdde-
    shell-dev 最低版本提升至 2.0.45,并通过 find_package 引入 DDEShell
  5. 重构 DesktopIntegration::launchByDesktopId() 方法,使用
    ds::XdgActivation 信号的异步令牌请求替代阻塞事件循环和超时机制
  6. 修复 bug:在 launcheritem.qml 中将 LauncherController.visible = false 移到 launchByDesktopId() 之后,确保启动完成后才隐藏启动器

Log: 使用 Dde::Shell 库替换内部 XDG 激活实现

Influence:

  1. 验证从启动器启动的应用能正确弹出窗口(防焦点窃取功能)
  2. 测试启动应用后启动器是否正常隐藏
  3. 确保在 X11 平台上的向后兼容性
  4. 检查令牌请求不会阻塞主线程
  5. 验证使用更新后的 libdde-shell-dev 版本构建成功
  6. 在未声明支持 xdg_activation_v1 的 Wayland 合成器上进行测试

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

Sorry @18202781743, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, BLumia

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

1. Remove custom XdgActivationV1 implementation in src/ddeintegration
2. Use ds::XdgActivation from Dde::Shell library instead
3. Refactor launchByDesktopId to use asynchronous token request
4. Update CMakeLists to link against Dde::Shell and raise libdde-shell-
dev dependency to >= 2.0.45
5. Remove wayland-protocols build dependency from debian/control
6. Remove obsolete HAVE_WAYLAND_XDG_ACTIVATION compile flag and related
conditionals
7. Fix launch order: move LauncherController.visible = false after
launch call to ensure proper window lifecycle

Log: Replaced customWayland XDG activation implementation with
Dde::Shell's standard XdgActivation API for improved maintainability and
compatibility with newer DDE versions.

Influence:
1. Verify application launch works correctly via desktop ID
2. Test XDG activation token flow on Wayland compositors
3. Ensure backward compatibility with older DDE versions that do not
provide Dde::Shell
4. Check build system changes do not break existing builds
5. Verify LauncherController visibility toggle works as expected after
launching apps
6. Test on both Wayland and X11 sessions (fallback behavior)
7. Verify token timeout and error handling (compositor not advertising
xdg_activation_v1)

feat: 使用 Dde::Shell 集成替换自定义 XDG 激活实现

1. 移除 src/ddeintegration 中的自定义 XdgActivationV1 实现
2. 改用 Dde::Shell 库中的 ds::XdgActivation
3. 重构 launchByDesktopId 使用异步令牌请求
4. 更新 CMakeLists 链接 Dde::Shell,并将 libdde-shell-dev 依赖提升至
>= 2.0.45
5. 从 debian/control 中移除 wayland-protocols 构建依赖
6. 移除已废弃的 HAVE_WAYLAND_XDG_ACTIVATION 编译标志及相关条件编译
7. 修复启动顺序:将 LauncherController.visible = false 移到启动调用之后
以确保窗口生命周期正确

Log: 用 Dde::Shell 提供的标准 XdgActivation API 替换了自定义的 Wayland
XDG 激活实现,提升了可维护性和与新版 DDE 的兼容性。

Influence:
1. 验证通过桌面 ID 启动应用程序功能是否正常
2. 在 Wayland 合成器上测试 XDG 激活令牌流程
3. 确保与不提供 Dde::Shell 的旧版 DDE 的向后兼容性
4. 检查构建系统变更不会破坏现有构建
5. 验证启动应用后 LauncherController 的可见性切换功能
6. 在 Wayland 和 X11 会话上测试(回退行为)
7. 测试令牌超时和错误处理(合成器未通告 xdg_activation_v1)

PMS: BUG-365883
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:90分

■ 【总体评价】

代码将同步阻塞获取Token改为异步获取,消除了死锁风险,但缺少超时与错误处理机制
评分理由:异步改造优秀,但未处理Token获取失败或超时的边界情况扣10分

■ 【详细分析】

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

launchByDesktopId 函数使用 ds::XdgActivation 异步获取 Token,逻辑清晰。但未处理 tokenReady 信号可能永远不触发的情况,例如底层 Wayland 协议异常、ds::XdgActivation 内部错误或未运行在 Wayland 环境下。
潜在问题:如果 requestToken 失败且未发出 tokenReady 信号,activation 对象将产生内存泄漏,且目标应用无法被启动。
建议:增加 QTimer 超时机制,在超时或错误发生时执行降级启动并调用 deleteLater() 释放对象。

  • 2.代码质量(良好)✓

移除了对 Qt6::WaylandClientPrivatewayland-protocols 的直接依赖,大幅降低了构建复杂度和 ABI 脆弱性。QML 中的顺序调整合理,确保了异步请求发起时 Launcher 仍具有焦点。
潜在问题:缺少对异步操作结果的完整性保障,防御性编程略显不足。
建议:补充超时处理的日志输出,考虑将 Token 获取与超时逻辑封装为独立的辅助函数以提高复用性。

  • 3.代码性能(高效)✓

彻底消除了原实现中 QEventLoop::exec 带来的嵌套事件循环开销和重入风险,避免了主线程最多 2 秒的阻塞等待,提升了启动器的响应流畅度。
建议:无需改进。

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

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
代码仅涉及内部组件调用和桌面应用启动,未引入命令注入、路径遍历等安全风险。移除对 Qt 私有头文件的依赖,减少了因底层 ABI 变动导致的潜在崩溃风险,提升了运行时的安全性。
建议:保持当前的依赖管理策略,避免引入未经审计的第三方私有 API。

■ 【改进建议代码示例】

void DesktopIntegration::launchByDesktopId(const QString &desktopId)
{
    qCInfo(logDesktopIntegration) << "Launching app by desktop ID:" << desktopId;
    auto *activation = new ds::XdgActivation(&instance());
    auto *timeoutTimer = new QTimer(activation);
    timeoutTimer->setSingleShot(true);
    timeoutTimer->setInterval(2000);

    // 使用 QObject::connect 处理超时和正常获取两种情况
    QObject::connect(timeoutTimer, &QTimer::timeout, &instance(), [desktopId, activation]() {
        qCWarning(logDesktopIntegration) << "XDG activation token request timed out, launching without token";
        AppInfo::launchByDesktopId(desktopId);
        activation->deleteLater();
    });

    QObject::connect(activation, &ds::XdgActivation::tokenReady, &instance(), 
        [desktopId, activation, timeoutTimer](const QString &token) {
            timeoutTimer->stop();
            if (!AppMgr::launchApp(desktopId, token)) {
                qCDebug(logDesktopIntegration) << "AppMgr launch failed, trying AppInfo launch";
                AppInfo::launchByDesktopId(desktopId);
            }
            activation->deleteLater();
        });

    timeoutTimer->start();
    activation->requestToken();
}

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.

3 participants