Skip to content

feat: add attention state support for treeland task manager#1599

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
18202781743:attention
Jun 1, 2026
Merged

feat: add attention state support for treeland task manager#1599
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
18202781743:attention

Conversation

@18202781743
Copy link
Copy Markdown
Contributor

@18202781743 18202781743 commented May 15, 2026

  1. Bump treeland-protocols dependency to version > 0.5.7 to ensure
    protocol compatibility
  2. Use local protocol XML file instead of system-installed one for
    easier development and stability
  3. Add Attention state handling to TreeLandWindow, enabling taskbar to
    reflect window attention state
  4. Update wayland extension versions to v2 for both
    ForeignToplevelHandle and ForeignToplevelManager to utilize new protocol
    features
  5. Implement isAttention() method to check attention state from foreign
    toplevel handle

Log: Taskbar now supports treeland window attention state display

Influence:

  1. Test taskbar window entries show attention state (e.g., flashing/
    urgent) when window requests attention
  2. Verify normal window behavior without attention state remains
    unchanged
  3. Test with treeland compositor version > 0.5.7 to ensure protocol
    compatibility
  4. Verify backward compatibility with older treeland versions (if
    applicable)
  5. Test attention state reset when window gains focus or user interacts
    with taskbar entry

feat: 为treeland任务管理器添加注意力状态支持

  1. 将treeland-protocols依赖提升至>0.5.7版本以确保协议兼容性
  2. 使用本地协议XML文件替代系统安装的协议文件,便于开发和保持稳定性
  3. 为TreeLandWindow添加注意力状态处理,使任务栏能够反映窗口的注意力请求
  4. 将ForeignToplevelHandle和ForeignToplevelManager的wayland扩展版本更新
    至v2,以利用新协议特性
  5. 实现isAttention()方法,从foreign toplevel handle中检查注意力状态

Log: 任务栏现在支持treeland窗口注意力状态显示

Influence:

  1. 测试任务栏窗口条目在窗口请求注意力时显示注意力状态(如闪烁/紧急状态)
  2. 验证无注意力状态的窗口行为保持不变
  3. 使用treeland合成器版本>0.5.7测试,确保协议兼容性
  4. 验证与旧版本treeland的向后兼容性(如适用)
  5. 测试窗口获得焦点或用户与任务栏条目交互时注意力状态重置

Summary by Sourcery

Add support for Treeland window attention state in the dock task manager and update Treeland Wayland protocol integration.

New Features:

  • Expose an attention state for Treeland windows so the task manager can reflect when a window requests attention.

Enhancements:

  • Update Treeland foreign toplevel handle and manager Wayland extensions to version 2 to use newer protocol capabilities.
  • Reference a local Treeland foreign toplevel manager protocol XML in the task manager build configuration for more stable protocol generation.

Build:

  • Adjust CMake configuration to use a project-local Treeland protocol XML file for generating Wayland client sources.

@18202781743 18202781743 marked this pull request as draft May 15, 2026 10:20
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 15, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds Treeland window attention state support in the dock task manager by updating the Treeland protocol usage, switching to a bundled XML protocol file, and wiring the new attention state into TreeLandWindow and its Wayland extensions.

Sequence diagram for Treeland attention state check in task manager

sequenceDiagram
    participant Taskbar
    participant TreeLandWindow
    participant ForeignToplevelHandle

    Taskbar->>TreeLandWindow: isAttention()
    TreeLandWindow->>ForeignToplevelHandle: state()
    ForeignToplevelHandle-->>TreeLandWindow:
    TreeLandWindow-->>Taskbar:
Loading

File-Level Changes

Change Details Files
Add attention state handling to TreeLandWindow and expose it via isAttention().
  • Extend the TreeLandWindow::State enum with an Attention value mapped to treeland_foreign_toplevel_handle_v1::state_attention.
  • Change TreeLandWindow::isAttention() from a hardcoded false return to querying the foreign toplevel handle state list for the Attention flag.
panels/dock/taskmanager/treelandwindow.h
panels/dock/taskmanager/treelandwindow.cpp
Update Wayland Treeland foreign toplevel client extensions to protocol version 2.
  • Bump ForeignToplevelHandle QWaylandClientExtensionTemplate version from 1 to 2 in its constructor.
  • Bump ForeignToplevelManager QWaylandClientExtensionTemplate version from 1 to 2 in its constructor.
panels/dock/taskmanager/treelandwindow.cpp
panels/dock/taskmanager/treelandwindowmonitor.cpp
Use a local Treeland foreign toplevel manager protocol XML instead of the system-installed one when generating Wayland client sources.
  • Point qt_generate_wayland_protocol_client_sources at a protocol XML under the taskmanager/protocol directory instead of TREELAND_PROTOCOLS_DATA_DIR.
panels/dock/taskmanager/CMakeLists.txt
Update copyright span for TreelandWindow source.
  • Extend the SPDX-FileCopyrightText year range to 2023-2026.
panels/dock/taskmanager/treelandwindow.h

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

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

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:

  • TreeLandWindow::isAttention() assumes m_foreignToplevelHandle is always valid and ready; consider guarding against a null or not-yet-initialized handle to avoid potential crashes during startup or teardown.
  • Now that the foreign toplevel extensions request version 2, it would be good to explicitly handle the case where the compositor only supports v1 (e.g., by checking the advertised version or feature flags) to preserve backward compatibility described in the PR.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- TreeLandWindow::isAttention() assumes m_foreignToplevelHandle is always valid and ready; consider guarding against a null or not-yet-initialized handle to avoid potential crashes during startup or teardown.
- Now that the foreign toplevel extensions request version 2, it would be good to explicitly handle the case where the compositor only supports v1 (e.g., by checking the advertised version or feature flags) to preserve backward compatibility described in the PR.

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 debian/control Outdated
@deepin-bot
Copy link
Copy Markdown

deepin-bot Bot commented May 20, 2026

TAG Bot

New tag: 2.0.42
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1603

@18202781743 18202781743 marked this pull request as ready for review May 27, 2026 05:41
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

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

@18202781743 18202781743 requested a review from wineee May 27, 2026 05:42
@deepin-bot
Copy link
Copy Markdown

deepin-bot Bot commented May 28, 2026

TAG Bot

New tag: 2.0.43
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1611

1. Bump treeland-protocols dependency to version > 0.5.7 to ensure
protocol compatibility
2. Use local protocol XML file instead of system-installed one for
easier development and stability
3. Add Attention state handling to TreeLandWindow, enabling taskbar to
reflect window attention state
4. Update wayland extension versions to v2 for both
ForeignToplevelHandle and ForeignToplevelManager to utilize new protocol
features
5. Implement isAttention() method to check attention state from foreign
toplevel handle

Log: Taskbar now supports treeland window attention state display

Influence:
1. Test taskbar window entries show attention state (e.g., flashing/
urgent) when window requests attention
2. Verify normal window behavior without attention state remains
unchanged
3. Test with treeland compositor version >= 0.5.7 to ensure protocol
compatibility
4. Verify backward compatibility with older treeland versions (if
applicable)
5. Test attention state reset when window gains focus or user interacts
with taskbar entry

feat: 为treeland任务管理器添加注意力状态支持

1. 将treeland-protocols依赖提升至>=0.5.7版本以确保协议兼容性
2. 使用本地协议XML文件替代系统安装的协议文件,便于开发和保持稳定性
3. 为TreeLandWindow添加注意力状态处理,使任务栏能够反映窗口的注意力请求
4. 将ForeignToplevelHandle和ForeignToplevelManager的wayland扩展版本更新
至v2,以利用新协议特性
5. 实现isAttention()方法,从foreign toplevel handle中检查注意力状态

Log: 任务栏现在支持treeland窗口注意力状态显示

Influence:
1. 测试任务栏窗口条目在窗口请求注意力时显示注意力状态(如闪烁/紧急状态)
2. 验证无注意力状态的窗口行为保持不变
3. 使用treeland合成器版本>=0.5.7测试,确保协议兼容性
4. 验证与旧版本treeland的向后兼容性(如适用)
5. 测试窗口获得焦点或用户与任务栏条目交互时注意力状态重置
@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, wineee, yixinshark

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

@deepin-ci-robot
Copy link
Copy Markdown

deepin pr auto review

你好!我是CodeGeeX。我已仔细审查了你提供的 Git Diff。本次代码变更主要涉及对 treeland-protocols 协议版本的升级(从 v1 到 v2),并在任务管理器中新增了对窗口“请求关注(Attention)”状态的支持。

以下是针对语法逻辑、代码质量、代码性能和代码安全方面的详细审查意见及改进建议:

1. 语法与逻辑

  • 逻辑完整性:状态枚举的同步与信号通知

    • 问题:你在 treelandwindow.h 中为 TreeLandWindow 增加了 Attention 枚举值,并在 isAttention() 方法中读取了该状态。但是,Wayland 窗口的状态是动态变化的,当底层 Wayland 协议通知窗口状态改变(例如应用调用 request_attention)时,AbstractWindow 需要发射信号通知 UI 层更新(例如在任务栏上闪烁提示)。
    • 建议:请检查 ForeignToplevelHandle 处理 treeland_foreign_toplevel_handle_v1::state 事件的回调函数(通常是 handle_state() 或类似重写的函数)。确保当底层传入 state_attention 时,能够正确解析,并且 TreeLandWindow 能够发射类似 attentionChanged 的信号。如果基类 AbstractWindow 没有通用的 attentionChanged 信号,建议补充,否则 UI 无法实时响应此状态的变化。
  • 逻辑一致性:协议版本与构造函数

    • 观察:你将 ForeignToplevelHandleForeignToplevelManagerQWaylandClientExtensionTemplate 模板版本从 1 升级到了 2,这与 debian/control 中要求 treeland-protocols (>= 0.5.7) 的约束是相呼应的,逻辑一致,没有问题。

2. 代码质量

  • 版权声明年份的修改

    • 问题:Diff 显示将版权年份从 2023 修改为了 2023 - 2026
    • 建议:在开源项目规范中,版权结束年份通常应该是代码首次发布或最后一次修改的实际年份(如 2023-2024),而不应该填写未来的年份(2026),除非有特殊的商业授权协议约定。建议修改为当前年份或仅保留原始创建年份。
  • 空指针解引用风险

    • 问题:在 TreeLandWindow::isAttention() 中:
      return m_foreignToplevelHandle->state().contains(Attention);
      这里直接对 m_foreignToplevelHandle 进行了指针解引用。如果由于 Wayland 协议时序问题,在对象销毁或未完全初始化时调用了 isAttention(),可能会导致空指针解引用引发崩溃。
    • 建议:增加空指针判断,或者使用 Qt 的安全指针机制:
      bool TreeLandWindow::isAttention() {
          return m_foreignToplevelHandle && m_foreignToplevelHandle->state().contains(Attention);
      }

3. 代码性能

  • 状态查询的效率
    • 观察m_foreignToplevelHandle->state() 每次调用都会返回一个状态列表,然后调用 contains 进行查找。
    • 建议:对于 Wayland 对象,通常会在内部缓存状态(例如使用 QVector<int> 或位掩码 QFlags)。如果 state() 每次都触发深拷贝或重新计算,建议在 ForeignToplevelHandle 内部将状态缓存为一个 QFlags<State> 或成员变量,isAttention() 直接读取缓存的标志位,这样可以避免频繁的容器构造与查找开销。如果 state() 本身就是返回缓存的 QVector,则当前实现性能可接受,但位运算效率更高。

4. 代码安全

  • Wayland 协议降级攻击防范
    • 观察debian/control 中限制了 treeland-protocols (>= 0.5.7),这是一个很好的安全实践,防止了在编译时链接到不支持 state_attention 的旧版协议库,从而避免运行时因协议不匹配导致的未定义行为或内存越界。
    • 建议:除了编译期依赖限制,在运行期(Runtime)也应考虑 Wayland 协议的版本协商。QWaylandClientExtensionTemplate<ForeignToplevelManager>(2) 会尝试绑定版本 2 的协议。如果运行环境中的 Wayland Compositor 较老,只支持版本 1,Qt 的 Wayland 绑定机制通常会绑定失败。请确保在 ForeignToplevelManager 初始化时检查 isInitialized() 或处理注册失败的情况,避免在 Compositor 不支持 V2 的情况下强行调用 V2 特有的接口导致异常。

总结

整体改动目标明确,代码精简。主要需要关注的是空指针防御状态变更信号的传递。建议修改后的核心代码如下:

// treelandwindow.cpp
bool TreeLandWindow::isAttention()
{
    // 增加空指针保护
    if (!m_foreignToplevelHandle) {
        return false;
    }
    return m_foreignToplevelHandle->state().contains(Attention);
}

同时,请务必确认底层 Wayland 事件回调中,当 Attention 状态改变时,是否有类似 Q_EMIT attentionChanged(isAttention()); 的逻辑被触发。

@18202781743
Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot
Copy link
Copy Markdown

deepin-bot Bot commented Jun 1, 2026

This pr force merged! (status: blocked)

@deepin-bot deepin-bot Bot merged commit 02c9293 into linuxdeepin:master Jun 1, 2026
9 of 12 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