Skip to content

feat(window-transition): use a live source surface for the transition - #115

Merged
zccrs merged 1 commit into
linuxdeepin:masterfrom
glyvut:feat/animation-new
Sep 22, 2026
Merged

zccrs merged 1 commit into
linuxdeepin:masterfrom
glyvut:feat/animation-new

Conversation

@glyvut

@glyvut glyvut commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor
  1. Replace set_source_buffer with set_source_surface taking a wl_surface

  2. Render the source surface live instead of sampling a one-off buffer

  3. Rename the invalid_buffer error to invalid_surface

  4. Clarify the closed event and the source surface lifetime contract

  5. 将 set_source_buffer 替换为接收 wl_surface 的 set_source_surface

  6. 源 surface 在转场中实时渲染,不再一次性采样 buffer

  7. 将 invalid_buffer 错误更名为 invalid_surface

  8. 澄清 closed 事件语义与源 surface 生命周期约定

Log: 转场源改用实时 surface,替代一次性 buffer

Influence:

  1. 用 wayland-scanner 重建协议头文件并确认无警告
  2. 将调用 set_source_buffer 的合成器/客户端改为 set_source_surface
  3. 验证源 surface 在打开/关闭转场中实时渲染且不重复显示

Summary by Sourcery

Replace one-off transition source buffers with live source surfaces and define their lifecycle and closure behavior.

New Features:

  • Use live Wayland source surfaces for window transitions, allowing transition content to update while playing.

Enhancements:

  • Clarify source-surface ownership, lifetime, reuse, and display restrictions during transitions.
  • Clarify rectangle closure semantics and the required client cleanup after the closed event.
  • Rename the invalid source error from invalid_buffer to invalid_surface.

Documentation:

  • Update the window-transition protocol documentation and public README descriptions for live source surfaces and revised lifecycle semantics.

@deepin-ci-robot

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@sourcery-ai

sourcery-ai Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Updates the window-transition protocol to use a live, compositor-exclusive wl_surface as its optional source, while removing buffer-release semantics, renaming the validation error, and clarifying source lifetime and rectangle completion behavior.

Sequence diagram for the live window transition source surface

sequenceDiagram
    participant A as SourceClient
    participant R as TransitionRect
    participant S as SourceSurface
    participant C as Compositor
    participant B as TargetWindow

    A->>R: set_geometry(x, y, width, height)
    A->>R: set_source_surface(S)
    A->>S: Commit live content
    A->>C: Pass activation token to B
    C->>B: Start open transition
    loop While transition is playing
        C->>S: Render latest surface content
        C->>B: Animate between source rect and window
    end
    B->>C: Close window
    C->>S: Render latest surface content
    C->>B: Animate close transition to source rect
    C-->>R: closed
    A->>R: destroy()
Loading

State diagram for the transition rectangle lifecycle

stateDiagram-v2
    [*] --> Configured: get_window_transition_rect
    Configured --> LiveSource: set_source_surface(surface)
    Configured --> Configured: set_geometry(...)
    LiveSource --> LiveSource: Surface content committed
    LiveSource --> Configured: set_source_surface(null)
    LiveSource --> Configured: set_source_surface(other_surface)
    Configured --> Transitioning: Target window starts transition
    LiveSource --> Transitioning: Target window starts transition
    Transitioning --> Transitioning: Render live source surface
    Transitioning --> Closed: Compositor done
    Closed --> [*]: destroy()
    LiveSource --> Configured: Source surface destroyed
Loading

File-Level Changes

Change Details Files
Replace one-off buffer snapshots with a live wl_surface transition source.
  • Replace set_source_buffer(wl_buffer) with nullable set_source_surface(wl_surface).
  • Render the source surface’s current content throughout the transition, scaled to the configured rectangle.
  • Define source-surface role, exclusivity, content-validity, replacement, and destruction requirements.
  • Rename the protocol error from invalid_buffer to invalid_surface.
public/treeland-window-transition-unstable-v1.xml
public/README.md
public/README.zh_CN.md
Clarify transition rectangle completion and cleanup semantics.
  • Require the client to destroy the rectangle after receiving closed.
  • Document that closed is sent when the compositor is done with the rectangle and no further events follow.
  • Clarify fallback behavior when the rectangle is destroyed or its client disconnects before completion.
public/treeland-window-transition-unstable-v1.xml
Update public protocol documentation for live transition sources.
  • Describe the optional source as a live surface rather than a source image.
  • Include set_source_surface in the usage sequence.
  • Update English and Chinese protocol summaries.
public/treeland-window-transition-unstable-v1.xml
public/README.md
public/README.zh_CN.md

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

@glyvut
glyvut marked this pull request as ready for review September 21, 2026 03:28

@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 found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="public/treeland-window-transition-unstable-v1.xml" line_range="169-190" />
<code_context>
+        <request name="set_source_surface">
</code_context>
<issue_to_address>
**issue (bug_risk):** This changes the wire contract of the existing v1 interface by removing `set_source_buffer` and changing its argument from `wl_buffer` to `wl_surface`, while retaining the same protocol and interface version. Clients using the published v1 XML send the old request and buffer object, which is incompatible with the new compositor-side request and can result in an invalid-object protocol error.

**Triggers:** When a client built against the previous v1 protocol communicates with a compositor built from this XML.

**Suggested fix:** Publish this incompatible contract as a new major protocol file/interface and retain the old v1 definition, or explicitly coordinate and document a breaking v1 replacement if this repository intentionally permits it.
</issue_to_address>

### Comment 2
<location path="public/treeland-window-transition-unstable-v1.xml" line_range="181-183" />
<code_context>
+                displayed anywhere else, and the client must not use it for any
+                other purpose.
+
+                The client must keep the surface alive, and keep valid content
+                on it, until the closed event is delivered, or until it clears
+                or replaces the source.
+
+                Passing null clears the source surface. The client may replace
</code_context>
<issue_to_address>
**issue (bug_risk):** The source-surface lifetime rule requires the client to keep the surface alive until `closed`, but destroying the rectangle before the target closes explicitly produces no `closed` event. The client therefore has no protocol notification that the compositor has released the source surface in this path and must either retain it indefinitely or risk destroying it while it is still referenced.

**Triggers:** When the client destroys the rectangle, disconnects, or its originating surface is destroyed before the target window closes.

**Suggested fix:** State that destroying the rectangle, disconnecting, or destroying the originating surface immediately releases the source surface, and define that the client may destroy the source surface after that operation; alternatively provide a release event/acknowledgement.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread public/treeland-window-transition-unstable-v1.xml
Comment thread public/treeland-window-transition-unstable-v1.xml Outdated
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 100 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
PR 链接 #115
PR 标题 feat(window-transition): use a live source surface for the transition
作者 glyvut
分支 feat/animation-new → master
修改文件 public/README.md, public/README.zh_CN.md, public/treeland-window-transition-unstable-v1.xml
变更统计 +43 / -43
审查结论 代码审查通过
评分详情 未发现安全问题,代码质量优良。本次变更将Wayland窗口转场协议从一次性buffer采样改为实时surface渲染,协议定义语法正确、逻辑清晰,文档注释完善,中英文README同步更新。变更合理且符合commit message所述目的。

📝 变更目的

本次 PR 的目的是将窗口转场协议中的源数据从一次性 wl_buffer 改为实时 wl_surface,具体包括:

  1. 将 set_source_buffer 替换为接收 wl_surface 的 set_source_surface
  2. 源 surface 在转场中实时渲染,不再一次性采样 buffer
  3. 将 invalid_buffer 错误更名为 invalid_surface
  4. 澄清 closed 事件语义与源 surface 生命周期约定

🔍 详细分析

1. 语法逻辑 ✓

评价: 语法正确,逻辑清晰 ✓

分析内容:

修改文件 public/treeland-window-transition-unstable-v1.xml 为 Wayland 协议定义文件,XML 语法正确,所有标签正确闭合,属性引用规范。

  1. set_source_surface 请求使用正确的 Wayland 协议 XML 语法:type="object", interface="wl_surface", allow-null="true",符合 Wayland 协议规范
  2. 错误枚举项 invalid_surface 保持 value="1",仅重命名 name 和 summary,与原 invalid_buffer 一致,不破坏协议兼容性
  3. closed 事件描述简化但逻辑一致:移除了"at most once per rectangle object"和"if the client destroys the rectangle (or disconnects) before then, this event is not sent"等冗余描述,步骤11中已覆盖该边界场景
  4. 步骤10缩进修正:原文本使用9个空格缩进( 10.),修正为8个空格( 10.),与其他编号项(1-9)保持一致
  5. 步骤3新增 set_source_surface 调用文档,位置正确——在 set_geometry 之后、commit 之前配置 rect 对象

潜在问题:
✅ 未发现明显问题

建议: 无需修改


2. 代码质量 ✓

评价: 代码结构清晰,注释完整 ✓

分析内容:

  1. set_source_surface 的描述文档详尽,清晰涵盖了以下关键语义:

    • surface 角色限制:"The surface must not already have a role"
    • 排他性约束:"the compositor reserves it for use as a transition source only: it is not displayed anywhere else, and the client must not use it for any other purpose"
    • 生命周期管理:"The client must keep the surface alive, and keep valid content on it, until the closed event is delivered, or until it clears or replaces the source"
    • 替换行为:"The client may replace the source by passing another surface; a previously set surface is no longer used as a source"
    • 清除操作:"Passing null clears the source surface"
  2. README.md 和 README.zh_CN.md 中英文同步更新,内容一致:

    • 英文:optional source image → an optional live source surface
    • 中文:可附带源图像 → 可附带实时源 surface
  3. XML 结构组织合理,请求、事件、错误枚举的顺序清晰

潜在问题:
✅ 未发现明显问题

建议: 无需修改


3. 代码性能 ✓

评价: 性能良好,资源使用合理 ✓

分析内容:

本次变更从一次性 buffer 采样改为实时 surface 渲染,实际上是性能改进:

  1. 避免了额外的 buffer 拷贝——原方案中合成器需要在 set_source_buffer 调用时采样 buffer 内容
  2. 允许合成器直接实时渲染 surface 内容,减少内存开销
  3. 实时 surface 渲染方式更符合 Wayland 的设计理念——surface 是活跃的对象,可以动态更新内容

潜在问题:
✅ 未发现明显问题

建议: 无需修改


4. 代码安全 ✓

评价: 存在0个安全漏洞 ✓

分析内容:

本次变更为 Wayland 协议定义文件修改,不涉及可执行代码,不存在安全漏洞。协议层面安全性良好:

  1. surface 角色约束:协议明确要求 "The surface must not already have a role",防止 surface 被复用于多个用途
  2. 排他性使用:协议规定 "the compositor reserves it for use as a transition source only: it is not displayed anywhere else, and the client must not use it for any other purpose",确保 surface 不会被滥用
  3. 错误处理:invalid_surface 错误正确处理无效 surface(如已有角色或无法用作转场源的 surface)
  4. 生命周期安全:通过 closed 事件明确 surface 生命周期,客户端在收到 closed 事件后才可销毁 rect 对象和释放相关资源
  5. 无敏感信息泄露
  6. 无用户输入校验问题(协议定义层)

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个

安全漏洞详情:
✅ 未发现安全漏洞

建议: 无需修改


📋 审查总结

维度 评分 满分 结果
语法逻辑 25 25 ✓ 通过
代码质量 25 25 ✓ 通过
代码性能 20 20 ✓ 通过
代码安全 30 30 ✓ 通过
总分 100 100 ✓ 通过

审查结论: 代码审查通过。本次 PR 将 Wayland 窗口转场协议从一次性 buffer 采样改为实时 surface 渲染,变更合理且符合 commit message 所述目的。协议定义语法正确、逻辑清晰,文档注释详尽完善,中英文 README 同步更新一致。未发现安全漏洞、语法错误、逻辑缺陷或性能问题。


本报告由 AI 代码审查工具自动生成
扫描时间:2026-09-21 11:35:00

@glyvut
glyvut marked this pull request as draft September 21, 2026 05:42
@glyvut
glyvut marked this pull request as ready for review September 22, 2026 03:21

@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 found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="public/treeland-window-transition-unstable-v1.xml" line_range="176-179" />
<code_context>
+        <request name="set_source_surface">
</code_context>
<issue_to_address>
**issue (bug_risk):** The request requires the source `wl_surface` to have no existing role, but does not define what happens when the surface has an existing role or how that condition maps to the new `invalid_surface` error. Clients cannot determine whether the request raises a protocol error, is ignored, or leaves the previous source active.

**Triggers:** When a client passes a role-assigned `wl_surface`.

**Suggested fix:** Explicitly state that this condition raises `invalid_surface` and define whether the previous source remains active or is cleared.

```suggestion
                The surface must not already have a role. If it does, this
                request raises the invalid_surface error, and any previously
                set source surface remains unchanged. The compositor reserves
                it for use as a transition source only: it is not displayed
                anywhere else, and the client must not use it for any other
                purpose.
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread public/treeland-window-transition-unstable-v1.xml Outdated
1. Replace set_source_buffer with set_source_surface taking a wl_surface
2. Render the source surface live instead of sampling a one-off buffer
3. Rename the invalid_buffer error to invalid_surface
4. Clarify the closed event and the source surface lifetime contract

1. 将 set_source_buffer 替换为接收 wl_surface 的 set_source_surface
2. 源 surface 在转场中实时渲染,不再一次性采样 buffer
3. 将 invalid_buffer 错误更名为 invalid_surface
4. 澄清 closed 事件语义与源 surface 生命周期约定

PMS: TASK-395857
Log: 转场源改用实时 surface,替代一次性 buffer

Influence:
1. 用 wayland-scanner 重建协议头文件并确认无警告
2. 将调用 set_source_buffer 的合成器/客户端改为 set_source_surface
3. 验证源 surface 在打开/关闭转场中实时渲染且不重复显示
@zccrs
zccrs added this pull request to the merge queue Sep 22, 2026
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: glyvut, zccrs

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

Merged via the queue into linuxdeepin:master with commit 296f4f3 Sep 22, 2026
4 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