Skip to content

fix: xembed tray icon not updated#475

Merged
BLumia merged 1 commit into
masterfrom
pms-bug-369271
Jul 7, 2026
Merged

fix: xembed tray icon not updated#475
BLumia merged 1 commit into
masterfrom
pms-bug-369271

Conversation

@BLumia

@BLumia BLumia commented Jul 7, 2026

Copy link
Copy Markdown
Member

修正treeland会话下xembed托盘图标不会更新的问题.

PMS: BUG-369271

Summary by Sourcery

Bug Fixes:

  • Clear X11 DAMAGE regions for damaged tray icon windows before notifying the tray manager so icons refresh properly in Treeland sessions.

修正treeland会话下xembed托盘图标不会更新的问题.

PMS: BUG-369271
Log:
@BLumia BLumia requested a review from tsic404 July 7, 2026 09:06
@sourcery-ai

sourcery-ai Bot commented Jul 7, 2026

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

Reviewer's Guide

Handles XDamage notifications for XEmbed tray icons by subtracting the reported damage region before notifying the tray manager, ensuring icons update correctly in treeland sessions.

Sequence diagram for handling XDamage notifications for XEmbed tray icons

sequenceDiagram
    participant XServer
    participant FdoSelectionManager
    participant Util
    participant X11Connection
    participant TrayManager

    XServer ->> FdoSelectionManager: nativeEventFilter(eventType, message, result)
    FdoSelectionManager ->> FdoSelectionManager: [responseType == m_damageEventBase + XCB_DAMAGE_NOTIFY]
    FdoSelectionManager ->> FdoSelectionManager: m_damageWatches.value(damagedWId)
    FdoSelectionManager ->> Util: instance()
    Util -->> FdoSelectionManager: Util
    FdoSelectionManager ->> X11Connection: getX11Connection()
    FdoSelectionManager ->> X11Connection: xcb_damage_subtract(connection, damageId, XCB_NONE, XCB_NONE)
    FdoSelectionManager ->> TrayManager: notifyIconChanged(damagedWId)
Loading

File-Level Changes

Change Details Files
Handle XDamage notify events by subtracting the damage region before notifying the tray manager so XEmbed tray icons repaint correctly.
  • Retrieve the damage ID associated with the damaged drawable from the damage watch map when a DAMAGE_NOTIFY event is received.
  • Guard against missing damage IDs before performing any XDamage operations.
  • Invoke xcb_damage_subtract with the current X11 connection and the retrieved damage ID, clearing the damage region.
  • Keep the existing call to notify the tray manager that the icon for the damaged window ID has changed.
plugins/application-tray/fdoselectionmanager.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 left some high level feedback:

  • In the DAMAGE_NOTIFY branch, consider explicitly checking m_damageWatches.contains(damagedWId) and possibly erasing the entry after xcb_damage_subtract to avoid relying on a default 0 value and to prevent repeated subtract calls on the same damage id.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In the DAMAGE_NOTIFY branch, consider explicitly checking `m_damageWatches.contains(damagedWId)` and possibly erasing the entry after `xcb_damage_subtract` to avoid relying on a default 0 value and to prevent repeated subtract calls on the same damage id.

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.

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:100分

■ 【总体评价】

代码完美修复了XCB Damage事件无限触发的问题,符合X11扩展标准使用范式
逻辑严密、质量优良且无任何安全风险,不扣分

■ 【详细分析】

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

在FdoSelectionManager::nativeEventFilter函数中,新增代码通过m_damageWatches.value获取damageId,并利用if(damageId)进行有效性校验,正确处理了哈希表中不存在的键返回默认值0的情况,避免了无效的XCB调用
建议:保持现有逻辑即可

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

代码简洁明了,变量命名damageId准确表达了业务含义,严格遵循了X11 Damage扩展的标准处理流程
建议:保持现有代码风格

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

m_damageWatches.value调用为O(1)时间复杂度的哈希查找,xcb_damage_subtract是处理该事件必须且唯一的X11客户端通信开销,整体性能表现优异
建议:无需优化

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

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
代码通过内部哈希表m_damageWatches对来源于X11事件的damagedWId进行严格校验,即使X11事件被同服务器恶意客户端伪造,也会因为找不到对应damageId而触发短路保护,不会产生越权操作或内存破坏

  • 建议:无需额外安全加固

■ 【改进建议代码示例】

// 当前代码已为最佳实践,无需修改,此处展示上下文完整逻辑以供参考
bool FdoSelectionManager::nativeEventFilter(const QByteArray &eventType, void *message)
{
    // ... 前置逻辑 ...
    } else if (responseType == m_damageEventBase + XCB_DAMAGE_NOTIFY) {
        const auto damagedWId = reinterpret_cast<xcb_damage_notify_event_t *>(ev)->drawable;
        const xcb_damage_damage_t damageId = m_damageWatches.value(damagedWId);
        if (damageId) {
            xcb_damage_subtract(Util::instance()->getX11Connection(), damageId, XCB_NONE, XCB_NONE);
        }
        m_trayManager->notifyIconChanged(damagedWId);
    }
    // ... 后置逻辑 ...
}

@BLumia BLumia requested a review from 18202781743 July 7, 2026 09:13
@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

@BLumia BLumia merged commit 407a4e3 into master Jul 7, 2026
11 of 14 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.

3 participants