Skip to content

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

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

feat: add attention state support for treeland task manager#1599
18202781743 wants to merge 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

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. 测试窗口获得焦点或用户与任务栏条目交互时注意力状态重置
@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-ci-robot
Copy link
Copy Markdown

deepin pr auto review

你好!我是CodeGeeX。我已经仔细审查了你提供的 Git Diff。这次修改的主要目的是为 treeland 的 Wayland 外壳协议扩展支持“请求关注(Attention)”状态,并将 Wayland 客户端扩展的协议版本从 1 升级到 2,同时更新了构建依赖的最低版本要求。

整体来看,修改逻辑清晰,目标明确。以下是我从语法逻辑、代码质量、代码性能和代码安全四个维度提出的详细审查意见和改进建议:

1. 语法与逻辑

  • 空指针解引用风险(高优先级)
    treelandwindow.cpp 中,isAttention() 方法的实现修改为:

    return m_foreignToplevelHandle->state().contains(Attention);

    这里存在潜在的空指针解引用风险。如果 m_foreignToplevelHandle 未初始化或为 nullptr,调用 ->state() 将导致程序崩溃。建议在调用前进行空指针检查。

  • Wayland 协议版本一致性(良好)
    你在 ForeignToplevelHandleForeignToplevelManager 的构造函数中,都将 QWaylandClientExtensionTemplate 的版本从 1 升级到了 2,并且在 debian/control 中添加了 treeland-protocols (>= 0.5.7) 的依赖限制。这保证了代码逻辑与构建依赖的一致性,逻辑非常严密。

  • 枚举作用域(建议优化)
    treelandwindow.h 中,你将 Attention 添加到了 TreeLandWindow 的枚举中:

    Active      = QtWayland::treeland_foreign_toplevel_handle_v1::state_activated,
    // ...
    Attention   = QtWayland::treeland_foreign_toplevel_handle_v1::state_attention

    由于 C++11 引入了强类型枚举 enum class,如果 TreeLandWindow 的枚举类型(如 State)不是 enum class,这些枚举值会泄漏到外层作用域。虽然这是原有代码的风格,但在新加代码时需注意 Attention 不要与全局宏或其他标识符冲突。

2. 代码质量

  • 版权声明年份规范(建议确认)
    treelandwindow.h 中,版权声明被修改为:

    // SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd.

    通常,开源项目的版权年份应该记录的是“代码首次创建到最近一次修改”的年份,例如 2023 - 2024(假设当前是2024年)。将结束年份写为 2026 这种未来的年份在开源社区规范中比较罕见,除非有特殊的商业授权协议。建议确认是否符合项目组的规范,通常建议写当前年份或仅写创建和修改年份。

  • 方法 const 正确性
    isAttention() 方法在逻辑上只读取状态,不修改对象成员,建议检查其声明是否为 bool isAttention() const;(原有代码中 allowClose() 也是类似只读方法,也应为 const)。如果是,这符合 const 正确性原则;如果不是,建议补全 const 修饰符。

3. 代码性能

  • Wayland 状态列表的查找性能(可接受,但可优化)
    state() 返回的通常是一个 QVectorQList,调用 contains() 的时间复杂度为 $O(N)$。但在 Wayland 协议中,一个窗口的状态数量通常极少(一般不超过 4-5 个,如 Active, Maximized, Minimized, Fullscreen, Attention)。因此,这里的 contains() 性能损耗可以忽略不计,当前写法可读性高,是合理的。
    优化建议(可选):如果未来状态量增多,或者该函数被高频调用(如每帧刷新),可以考虑将状态存储为 QFlags<State>(位掩码),这样 contains 就变成了位运算,时间复杂度为 $O(1)$。但这取决于 QtWayland 生成的底层接口,如果底层就是返回 List,则当前实现已是最优解。

4. 代码安全

  • 防御性编程(关键)
    如前文所述,Wayland 对象的生命周期由服务端( compositor )控制,当窗口被关闭或服务端销毁资源时,ForeignToplevelHandle 的指针可能变为无效。必须确保在使用前检查指针的有效性。

改进后的代码建议

针对 treelandwindow.cpp 中的 isAttention() 方法,建议修改为如下防御性写法:

修改前:

bool TreeLandWindow::isAttention()
{
    return m_foreignToplevelHandle->state().contains(Attention);
}

修改后:

bool TreeLandWindow::isAttention() const // 建议加上 const 修饰
{
    if (!m_foreignToplevelHandle) {
        qCWarning(waylandwindowLog) << "ForeignToplevelHandle is null in isAttention";
        return false;
    }
    return m_foreignToplevelHandle->state().contains(Attention);
}

(注意:请同步在 treelandwindow.h 中将声明改为 bool isAttention() const;)

关于版权年份的建议:
如果当前年份是 2024,建议修改为:

// SPDX-FileCopyrightText: 2023 - 2024 UnionTech Software Technology Co., Ltd.

总结

这次 Diff 的核心功能实现没有问题,依赖版本限制非常到位。主要的风险点在于 空指针解引用,建议加上非空校验以增强代码的健壮性。版权年份的问题建议与团队确认是否符合内部规范。其余部分质量很高,可以合并。

@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

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