Skip to content

feat: add pid and AM-based appid query fallback for wayland session#1652

Merged
BLumia merged 1 commit into
linuxdeepin:masterfrom
BLumia:pms-bug-360357
Jun 24, 2026
Merged

feat: add pid and AM-based appid query fallback for wayland session#1652
BLumia merged 1 commit into
linuxdeepin:masterfrom
BLumia:pms-bug-360357

Conversation

@BLumia

@BLumia BLumia commented Jun 24, 2026

Copy link
Copy Markdown
Member

为 treeland 会话增加基于 pid 反查归属应用 appid 信息的逻辑.

PMS: BUG-360357

Summary by Sourcery

Enhancements:

  • Include the window process ID alongside the app ID in Treeland window identity queries to support PID-based fallback lookup.

@BLumia BLumia requested a review from tsic404 June 24, 2026 09:32
@sourcery-ai

sourcery-ai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Extends TreeLandWindow identity information to include both the Wayland foreign toplevel appid and the window’s process ID, enabling PID- and app-id–based fallback identification for Wayland sessions.

File-Level Changes

Change Details Files
Extend TreeLandWindow::identity() to return both the Wayland appid and the window PID for improved app identification in Wayland sessions.
  • Refactor identity() to build a QStringList result instead of returning a temporary initializer list.
  • Append the foreign toplevel handle appid (or empty string) as the first element in the identity list.
  • Append the stringified process ID from pid() as a second element in the identity list to support PID-based lookup.
panels/dock/taskmanager/treelandwindow.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

@BLumia BLumia requested a review from 18202781743 June 24, 2026 09:33

@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 left some high level feedback:

  • Callers of identity() previously received a single-element list containing only the appid; adding the PID as a second element changes that contract, so please verify and adapt all call sites to handle the new structure rather than assuming index 0 is the sole identity.
  • Consider omitting the PID or appid when they are invalid (e.g., empty appid or pid() returning 0/negative) instead of always pushing two entries, to avoid propagating meaningless identifiers into consumers of identity().
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Callers of `identity()` previously received a single-element list containing only the appid; adding the PID as a second element changes that contract, so please verify and adapt all call sites to handle the new structure rather than assuming index 0 is the sole identity.
- Consider omitting the PID or appid when they are invalid (e.g., empty appid or `pid()` returning 0/negative) instead of always pushing two entries, to avoid propagating meaningless identifiers into consumers of `identity()`.

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.

为 treeland 会话增加基于 pid 反查归属应用 appid 信息的逻辑.

PMS: BUG-360357
Log:
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

@BLumia BLumia merged commit 76e5168 into linuxdeepin:master Jun 24, 2026
8 of 12 checks passed
@BLumia BLumia deleted the pms-bug-360357 branch June 24, 2026 09:41
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:100分

■ 【总体评价】

代码完美修复了多实例窗口标识冲突的逻辑缺陷
逻辑严密且无任何安全与性能风险,符合满分标准

■ 【详细分析】

  • 1.语法逻辑 完全正确 ✓

使用三元运算符安全处理了 m_foreignToplevelHandle 可能为空指针的情况,QString::number 类型转换准确,通过追加 pid() 精准解决了同应用多实例无法区分的核心问题

  • 2.代码质量 良好 ✓

代码修改精简直观,无冗余逻辑,变量提取与列表初始化方式符合 C++ 规范及项目现有风格

  • 3.代码性能 高效 ✓

仅增加一次极低开销的 pid() 系统调用与轻量级整型转字符串操作,对任务栏窗口匹配性能无任何负面影响

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

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
代码未引入任何外部输入、命令执行、内存越界或敏感信息泄露风险,进程号属于非敏感系统基础信息

■ 【改进建议代码示例】

diff --git a/panels/dock/taskmanager/treelandwindow.cpp b/panels/dock/taskmanager/treelandwindow.cpp
index c9dd3701a..54b338596 100644
--- a/panels/dock/taskmanager/treelandwindow.cpp
+++ b/panels/dock/taskmanager/treelandwindow.cpp
@@ -144,7 +144,14 @@ pid_t TreeLandWindow::pid()
 
 QStringList TreeLandWindow::identity()
 {
-    return QStringList{
-        (m_foreignToplevelHandle ? m_foreignToplevelHandle->appid() : ""),
-        QString::number(pid())
-    };
+    QString appId = m_foreignToplevelHandle ? m_foreignToplevelHandle->appid() : "";
+    qint64 currentPid = pid();
+    
+    // 防御性检查:确保获取到的 pid 合法有效,避免无效进程 ID 污染窗口标识列表
+    if (currentPid <= 0) {
+        return QStringList{appId};
+    }
+    
+    return QStringList{
+        appId,
+        QString::number(currentPid)
+    };
 }

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